I have a problem with date and time picker when i select the date from dtpicker1 then txtdate1 gets the value but when i debug it shows txtdate1 = "" why please help

Private Sub DTPicker1_CloseUp()
txtdate1.Text = DTPicker1.Value
DTPicker1.Refresh
End Sub

Maybe it's because you place your code at the CloseUp event of the date picker, it seems that when the CloseUp event is being fired, the Value property still doesn't have the date selected...

why not change the event?, try to put it in LostFocus or Click events of the date picker...

Remove the refresh statement, it should solve your problem. Also, as PoisenedHeart pointed out, under your click event.

Also check your code that you are not calling a clean up of all text in your text boxes.

No, you won't call clean up, just check if you do not have it in your code somewhere in the form -"Text1.Text = "" or Text1.Text = vbNullString".

This is also maybe why your textbox is cleared. If you do not have it, don't worry about it.:)

Edited 5 Years Ago by AndreRet: n/a

Its showing the date in textbox but when i click on calculate button it gives message invalid use of null but when i pass dates manually and click on calculate button then it perform calculation

The error "Invalid use of Null" means that you are trying to divide a number by zero.

Write some error trapping code just before the calculation -

If Text1.Text = vbNullString Then
msgbox "Add a number/date"
Else
'Do calculation
End If

Dear AndreRet i have resolved the problem by using validate event now it is working perfectly any way thanks for your kind and great help

This question has already been answered. Start a new discussion instead.