PDA

View Full Version : [SOLVED:] DTPicker Control in User Form



stevetalaga
03-17-2014, 03:33 AM
I'm using the DTPicker control in a user form to pop up a calendar so that the user can select a date.

Any clues please on how to set the default date property "Value" to the current date? In the Properties table I tried setting it to things like "Date", "Date()", "Today", "Today()" and Null but each time I get an error message saying "Invalid Property Value" and it inserts the current date and time as "3/17/2014 6:20:37 PM". That's great for right now but it's wrong for tomorrow.

Thanks

stevetalaga
03-17-2014, 03:52 AM
Cracked it :)

I set the property to "Date" when the form opens...I'm still very much a novice here!


Private Sub UserForm_Activate()
calJoiningDate.Value = Date
End Sub

snb
03-17-2014, 05:24 AM
It's more obvious to use the Userform_Initialize event in this case.

stevetalaga
03-17-2014, 07:10 AM
Thanks snb, if that's the preferred way I will do that.

Next task / learning is to get the selected date into a Word document, at a bookmarked location. Simple stuff I'm sure but just got to find it out :)

snb
03-17-2014, 07:54 AM
I'd prefer a docvariable to do this.


Activedocument.variables("mydate")=dtpicker.value
activedocument.fields.update

You can insert one of Word's fields like this: ctrl-F9 { DOCVARIABLE mydate }