Ignore the suggestion to use the on-load event (that event always fires when
the form loads).
Remember, that a user might navigate to a new blank record, and then decide
to close the form. You don't want to 'dirty' the form unless the user
actually tries to edit (else, when your close the form..you will write out a
blank record..and you don't want blank records strewn all over the place).
To capture the user (and time) of when a new record is created in a form,
you use the before-insert
The advantage of using before-insert is:
It ONLY fires WHEN a NEW record is created by the user. (on-load always
fires)
You do NOT have to check the 'new record status', nor do you need to
check if the field values are already set (they can't be set..since the
record is *just* being created - again a problem if you use on-load
So, by choosing the correct event, you avoid dirtying a record until the
user actually types something. You avoided having to write extra code to
"check" if this a new record. And, you avoid having to check if the values
are already set (since before-insert can only fire once when the record is
cared).
So, in the before-insert event, you simply go
me!myusername = currentUSER() ' or whatever expresson you have to set the
user name
me!myTimeStamp = now() ' now is date + time combined
So, two lines of code is all you need if you choose the correct event
here....