Auto date insertion into a form field

Johnny Drama

In need of beer...
Local time
Today, 14:59
Joined
Dec 12, 2008
Messages
211
Hi all,

This is probably way more simple than I can imagine, but for the life of me I can't figure out how to work this.

I have a simple table with three fields in it, one of which is date/time. I have a form for entering data into that table and all I'm trying to do is have the date automatically populate the date/time field when the form is opened. I've tried every different way I can think of, but no dice.

Any ideas?

Thanks in advance.
 
If you only want to do this when a new record is created, for date and time
Code:
Private Sub Form_Current()
 If Me.NewRecord Then
   Me.DateOriginated = Now
 End If
End Sub

For date alone

Code:
Private Sub Form_Current()
 If Me.NewRecord Then
   Me.DateOriginated = Date
 End If
End Sub
 
Yep, that's it. Thanks!
 
And a simpler way is to just go to the table, and in the DEFAULT for that field put

Now()

might need =Now() as I can't remember for sure.

and it will automatically put in the date/time WITHOUT code for a new record.
 

Users who are viewing this thread

Back
Top Bottom