View Full Version : Updated by user field


Kriv
02-19-2008, 09:56 AM
Access 2000:

There is probabily a simple function that can do this, but I'm stuck to find any explanation so I was hoping someone could help. I've tried the forum search but I guess I'm looking for the wrong thing.

I have managed access to the databse using the users/groups facility. So everyone who accesses the database has to effectively log in.

Users will be creating a record in only one table. When they save this record I need Access to automatically populate a designated field with the Users Log On name.

My question is how?

Thanks in advance for your time.

pbaldy
02-19-2008, 10:03 AM
Try a default value of

=CurrentUser()

Kriv
02-19-2008, 10:06 AM
So simple, many thanks for your prompt reply! I wasn't too far off I tried '=user()'

pbaldy
02-19-2008, 10:52 AM
No problem; you were close!

Kriv
02-20-2008, 08:07 AM
Actually I'm nowhere near close. Something is just not going right here.

Here is what I have done.
Created a new field, data type is Text, all field properties are default apart from the default value, which has been manually set to =CurrentUser()

(The case has been preserved)

When I entered this and attempted to save the table I receive the error "Unknown function 'CurrentUser' in validation or default value on 'Table1.text'.

I've tried creating this on a blank database to, and still have this issue.

Help still appreciated!

gemma-the-husky
02-20-2008, 08:44 AM
create a hidden control (or visible locked control) on the record bound to the relevent username field in the underlying table

actually, typically you could have fields for

created by
created on
last edited by
last edited on

then in the before update event for the form - ie as you save the edited record

put

createdby = currentuser()
createdon = date() {or createdon = now() }
etc

pbaldy
02-20-2008, 08:47 AM
I don't normally use the built in security, but a brief test confirms your error. I was successful in making it the default value on a form bound to a table though. Does that work for you?

Kriv
02-21-2008, 02:36 AM
Thank you both for your suggestions, sadly I don't know how to put them into practice as the terminology used is a little above my head.

Would it be possible for you to describe how I go about this in laymans terms? If not is there a good online resource you suggest can lead me through this step by step, as I can appreicate you might not want to describe the whole process/

Kriv
02-26-2008, 07:30 AM
Can anyone assist?

I now have the current user displaying on a form, but not too sure how I get this information to save in the table.

pbaldy
02-26-2008, 08:28 AM
Bind the control to the table and use CurrentUser() as the default value.

Kriv
02-26-2008, 08:37 AM
Hi Guys & Gals, thanks for the previous help. It got me on the right track.

Here is what I did (after a bit of playing about). Just incase anyone has this issue in the future here is what I did.

Please note the limitations of this is that it will only store the details of the last user who updated the record, it will not keep track of historical changes etc.


- On the table where you need to define this create a field called ChangedBy
- Open your form that you are using to input the data
- Right mouse click on a data entry field and select properties
- Click the tab Event
- Create a new Event Procedure by clicking on the ...
- Paste in the following code ChangedBy = Application.CurrentUser
- Save your changes

Now when you tab out of this field the data will update. You can also apply this to any button etc, for example bind it to one that will save your record.

Kriv
02-26-2008, 08:39 AM
Pbaldy, many thanks, you've probabily said something similar to my post above, but I'm not used to the terminology (yet)

Thanks for taking the time out to look into my issue, much appreciated.