Automatically update date/time field

vexing

Registered User.
Local time
Today, 21:09
Joined
Sep 15, 2000
Messages
15
I am having trouble with a time field in a form. The problem is:

The time field is set to default of '=time$()' so the time field is filled in automatically with the current time. Problem is, I need the time field to only fill itself in AFTER the record is entered, not at the beginning. Reason for this is that when a record is opened, it may sit there for hours before any info is actually entered into it. If the time is filled in when the record is opened, by the time the record is finished, it would be way off... I have tried to creat an event procedure to assign the '=time$()' command to happen 'After Update' but can't get it to work. Can anyone give my some help, advice, or code samples?
 
Try using the "Before Insert" event of the form to do what you need:

Private Sub Form_BeforeInsert(Cancel As Integer)
Me![YourTimeEntry] = Time$()
End Sub

"YourTimeEntry" needs to be the name of the control that you using to record the Time value.

HTH
RDH
 
Thanx for your help,
I think I got it working. This is what I'm using:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.Date = (Now)
Me.Time = (Now)
End Sub
 
You don't need two separate fields to store date and time one field will record both.
 

Users who are viewing this thread

Back
Top Bottom