Hi all
Usually trawl these forums for help but I've been struggling with this one and just found the answer. Time to give back!
My project requires users to specify a date & time for when they want the record to expire and so it seemed more useful to have the dtpicker default to the current date & time instead of having an arbitrary value assigned in the dtpicker properties. I use two separate dtpickers, one for date (dtpdate) and one for time (dtptime).
Based upon a post in a non-tek-tips forum, it was suggested to set the dtpicker to enabled=true before updating the value of the dtpicker, and to do so in the Form-Load event. This worked, however I discovered that it would not let me then goto a new record in the Form_Open event.
The issue is resolved by setting the dtpicker to visible=True in the Form_Load event, then the Form_Open event can execute the new record without dtpicker error:
Works a treat for me. Hope it helps.
Cheers all
xentaur
Usually trawl these forums for help but I've been struggling with this one and just found the answer. Time to give back!
My project requires users to specify a date & time for when they want the record to expire and so it seemed more useful to have the dtpicker default to the current date & time instead of having an arbitrary value assigned in the dtpicker properties. I use two separate dtpickers, one for date (dtpdate) and one for time (dtptime).
Based upon a post in a non-tek-tips forum, it was suggested to set the dtpicker to enabled=true before updating the value of the dtpicker, and to do so in the Form-Load event. This worked, however I discovered that it would not let me then goto a new record in the Form_Open event.
The issue is resolved by setting the dtpicker to visible=True in the Form_Load event, then the Form_Open event can execute the new record without dtpicker error:
Code:
Private Sub Form_Load()
Me.dtpdate.Visible = True: Me.dtptime.Visible = True
Me.dtpdate.Object.Value = Now()
Me.dtptime.Object.Value = Now()
End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.RunCommand acCmdRecordsGoToNew
End Sub
Works a treat for me. Hope it helps.
Cheers all
xentaur