New Form and date button

phillsheen

Registered User.
Local time
Today, 13:19
Joined
Jun 12, 2006
Messages
86
Hi,
This is a simple problem but I cant seem to find the right code to go with it. I have one with one field and one button. What I want to do is when the button is pressed a new record is created (done this part already) and the date is automatically filled into the date field. This is the part Im having trouble with. Ive used the following code but Im sure Ive got the wrong idea totally.

Code:
Private Sub Form_AfterUpdate()
Me.Date = Date 'Display date
End Sub

Its worth memtioning that the date field is indexed and no duplicated can be made. So in other words there can only be one record per day.

Any help would be fantastic!

Cheers
Phill
 
You can set the default property in the underlying table to be Date(), so when you add a new record, it is already populated
 
That works!
Cheers
 
And for heaven's sake, if you have DATE as a column name, rename it because DATE is an Access Reserved word and you will find yourself having issues with this as you go along.
 

Users who are viewing this thread

Back
Top Bottom