Capture user name on New Records only.

G

Guest

Is it possible to capture user at time of new record creation, and keep that
name on the form, regardless of updates and edits.

I am using capture user on a splash screen, but using before or after update
on athe main form would not work as we use the same form to search as well as
to add new records.

Much thanks in advance.
 
G

Guest

Capture it in the Form Load event. Create a text box to contain it. If you
don't want the user to see it, make it invisible.
 
G

Guest

Hi Klatuu, thanks for response.

Quick question. With the OnLoad, this will only apply to new records, and
not when people go back to form to edit, is that correct????

Sorry for this, not quite sure.

Thanks agains.
 
G

Guest

Not by itself. What you will need to do is make it the Default Value of the
control where it goes in the table.
 
A

Albert D.Kallal

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....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top