Unfortunately I think u didnt get my exact problem.
Which is why I asked questions.
What happened is, the form's before insert event was fired when the new record got the focus and it is not firing again before inserting the record.
The before insert event fires just before the new (blank) record is created in the table. It only fires when a new record is created, so it won't fire again.
For example
i have 5 fields in my form which include Name, age,city, start time and end time. I have wrtiten the following code in form'before update event
<Code>
Private Sub Form_BeforeInsert(Cancel As Integer)
txtEndtime = Format(Now, "dd/MM/yy hh:mm ss")
End Sub
</code>
The above event got fired when the new record got focus in first field. Suppose i have started code at "10/07/2011 10:10:10" and end time has that value. After filling all records and when moving to new record, the form's before insert event is not firing again hence the end time remains at
"10/07/2011 10:10:10". This is the problem i'm facing.
Please Suggest me.
I would use the form before update, not the before insert.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
txtEndtime = Now()
End Sub
Formatting the date/time only affects how data is displayed, not how it is stored in the table, so it is not needed.