Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Time Picker vs accmdrecordsgotonew

Status
Not open for further replies.

xentaur

Programmer
Nov 17, 2003
35
AU
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:

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 [wink]

xentaur
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top