PDA

View Full Version : DTPicker giving time not date.



JordanGoodch
12-27-2011, 04:58 PM
i have a DTpicker which is formated as dtpShortDate yet when it is run the value from the DTPicker is 12:00:00 AM how can i get it to stop doing this and make th value the date selected.

Bob Phillips
12-27-2011, 05:20 PM
Post the workbook for us to look at.

JordanGoodch
12-27-2011, 05:26 PM
I have attached the document.

Cheers.

Bob Phillips
12-27-2011, 05:34 PM
I don't seemto have that DTPicker object. Where did you get it from?

JordanGoodch
12-27-2011, 05:53 PM
right click on the toolbox toolbar and select additional controls and it is under microsoft date and time picker

Bob Phillips
12-28-2011, 05:11 AM
Assuming you mean the date on the userform, that returns a date for me in the format dd/mm/yyyy.

Kenneth Hobs
12-28-2011, 07:15 AM
NA

Aflatoon
12-28-2011, 07:35 AM
That control loses its value for some reason when you switch tabs. (some controls do not appreciate being on a multipage control very much). A simple solution would be to use the Change event of the control to store the date value in a variable, and then refer to that variable when saving the data.

Bob Phillips
12-28-2011, 08:22 AM
That control loses its value for some reason when you switch tabs. (some controls do not appreciate being on a multipage control very much).

Can you elaborate on that, I am not seeing any abnormal behaviour whatsoever?

Aflatoon
12-28-2011, 08:39 AM
What does the message box (and output cell) say when you press the Save button at the bottom of the second tab?

Kenneth Hobs
12-28-2011, 08:41 AM
It does as Aflatoon said for me. Here is my work-around. I more fully qualified the control though it is not needed in this case.
Private dt As String

Private Sub UserForm_Initialize()
MultiPage1.Pages("Page1").DTPicker1.Value = Date
dt = Format(MultiPage1.Pages("Page1").DTPicker1.Value, "mm/dd/yyyy")
End Sub

Private Sub DTPicker1_Change()
dt = Format(MultiPage1.Pages("Page1").DTPicker1.Value, "mm/dd/yyyy")
End Sub

Private Sub CommandButton1_Click()
MsgBox dt
End Sub

JordanGoodch
12-28-2011, 08:56 PM
Thank you very much for all of your help. I will try this method tomorrow and test it.