recording which user last modified a record

A

Anthony

i know about currentuser() and the api code, but i'm new
too Access so I'm not sure how use the function or the code

i've created a data entry form...what i want is the
following:

1) a user opens the form and makes changes to any of the
fields

2) Access gets the current username and enters it into a
field on the same form called "Last modified by"

3) the username is saved in the field for only the
particular record that has been modified ...i.e. if i go
to any other records i should see the names of different
users who were the ones to last modify a record
 
R

Rick Brandt

Anthony said:
i know about currentuser() and the api code, but i'm new
too Access so I'm not sure how use the function or the code

i've created a data entry form...what i want is the
following:

1) a user opens the form and makes changes to any of the
fields

2) Access gets the current username and enters it into a
field on the same form called "Last modified by"

3) the username is saved in the field for only the
particular record that has been modified ...i.e. if i go
to any other records i should see the names of different
users who were the ones to last modify a record

In the BeforeUpdate of the form put code similar to. . .

Me![Last Modified By] = CurrentUser()
 
A

Anthony

please show me step by step

-----Original Message-----
what would Me stand for?


-----Original Message-----
Anthony said:
i know about currentuser() and the api code, but i'm new
too Access so I'm not sure how use the function or the code

i've created a data entry form...what i want is the
following:

1) a user opens the form and makes changes to any of the
fields

2) Access gets the current username and enters it into a
field on the same form called "Last modified by"

3) the username is saved in the field for only the
particular record that has been modified ...i.e. if i go
to any other records i should see the names of different
users who were the ones to last modify a record

In the BeforeUpdate of the form put code similar to. . .

Me![Last Modified By] = CurrentUser()



.
.
 
R

Rick Brandt

Anthony said:
please show me step by step

Open your form in design view and open the properties
dialog.

Click on the small square in the upper left-hand corner of
the form window to insure that the property sheet is
displaying properties for the form and not some control or
section.

Find the Open event property for the form on the Events tab
and double-click on it. This should cause the entry "[Event
Procedure]" to appear in the box. If it doesn't, drop the
selection list down and select this entry from the list.

Once "[Event Procedure]" is shown in the box click on the
build button to the right [...].

You are now in a code module window and Access has already
added lines for you to start and end the event sub-routine.
Put the line of code between the start and end sub lines and
that's it.
 
A

Anthony

Thank You. I entered the code for the AfterUpdate event
because I wanted to get current user after a record has
been modified.

Just one more thing though. The field "Last modified by"
shows my username for every record - not just the one I
modified.


-----Original Message-----
Anthony said:
please show me step by step

Open your form in design view and open the properties
dialog.

Click on the small square in the upper left-hand corner of
the form window to insure that the property sheet is
displaying properties for the form and not some control or
section.

Find the Open event property for the form on the Events tab
and double-click on it. This should cause the entry "[Event
Procedure]" to appear in the box. If it doesn't, drop the
selection list down and select this entry from the list.

Once "[Event Procedure]" is shown in the box click on the
build button to the right [...].

You are now in a code module window and Access has already
added lines for you to start and end the event sub- routine.
Put the line of code between the start and end sub lines and
that's it.


.
 
R

Rick Brandt

Anthony said:
Thank You. I entered the code for the AfterUpdate event
because I wanted to get current user after a record has
been modified.

No. It must be BeforeUpdate. If you modify the record in
the AfterUpdate, guess what? You will cause another Update
event to occur and you will cause an endless loop.
BeforeUpdate means after a user has entered changes, but a
split second before the record is saved. That is where you
want to do this.

Just one more thing though. The field "Last modified by"
shows my username for every record - not just the one I
modified.

Did you bind the control on the form to a field in the
table? If not then you aren't storing anything. You are
just displaying some text on the form that will be gone as
soon as you close it.
 
A

Anthony

THANK YOU SO MUCH!! YOU DON'T KNOW HOW LONG I'VE BEEN
TRYING TO FIGURE THIS OUT! YOUR A GENIUS!
 

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