Me!NameOfTextBox = Date()
If you want it updated when the form is opened and/or when the user moves to
a new record, you'll need to place the code in Current event. This event is
fired whenever the form moves to a record, including when the form is opened
and moves to the first record, so if you have it in the Current event
there's probably no need to have it in the Open or Load events as well.
Updating it when the form is closed is, I think, problematic. If it's a
bound control (you're storing this date in a field in the table the form is
bound to) I think that's going to be a problem, because changes are saved
*before* the form's Unload or Close events are fired. If it's an unbound
control, there wouldn't be any point in setting it in the Unload or Close
events, as no one would see it until they opened the form again, when it
would be reset anyway.
If you just want it updated when the record is saved, then the BeforeUpdate
event of the form would be the event to use.
--
Brendan Reynolds (MVP)
NNester said:
Hi,
I have an "EditDate" field on a form that I want to automatically update
to today's date either when the form is opened, closed, or when the user
moves to another record. I'm pretty sure I need code in the OnOpen or
BeforeUpdate form property but I can't seem to get it right. Can anyone
help me?