Don said:
I have a field in a table that I want to populate with the current date and
time when the user starts to use the form. Can someone tell me how to code
this. I think I use the BeforeUpdate property but can't make it work.
If you're not trying to capture the exact moment that the record is saved you
can just set the DefaultValue property of the TextBox to =Now(). That will
capture when the new record position is painted by the form. In other words the
user could navigate to the New Record position and then let the form sit like
that indefinitely. Whenever they do finally get around top creating a record
you will still get the time from when they navigated to the new record position.
If you use the BeforeInsert event to "push" Now() into a TextBox then you will
capture the time that the user actually began typing data into the new record.
Again though, they could start typing and then go to lunch. When they finish and
save the record the time captured could be stale. The code would look like...
Me!TextBoxName = Now
If you want to capture the exact time of the record being saved then you need
the BeforeUpdate event which fires just before the record is committed to disk.
The difference though is that BeforeUpdate can fire many times for a single
record so you need an If-Then statement to ensure that the time is only captured
once...
If IsNull(Me!TextBoxName) Then Me!TextBoxName = Now