Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto Tracking of Operator Id

Status
Not open for further replies.

noelville

Programmer
Jan 20, 2009
14
0
0
CA
Wishful thinking, but is there a way to have the operator id in a table set to the operator who created the record (their signon id) e.g. using the default property, etc.
I know how to do this in a form but there are quite a few forms that would require changing as well as updating the changed forms on many computers.
Thanks Alex
 
Yes you can do this. If you know how to build a function that does this for a form you can set the default value of a table to a function.

so build a function
public function getPK() as string
'some function here to determine the user name
'determine the last id in table
'create a new key
end function

in the table default value
=getPK()

However if you are currently using an AutoID you can simply add another field for UserCreated in the table. Set the default for that field to a function that returns the user. There really is not a good reason to make the PK contain the user id. Just let the PK be unique and have another field for user. You can always concatenate this info for visibility.
 
FYI. I have not seen it yet but I have read that 2010 has table level events called data macros. So lets say you wanted to track the last person working the record. Currently you can only do that at the form level. But data macross would be like you were asking were the event would occur whenever table is effected. See here:

Anyone using these in 2010 have info/opinions?
 
MajP, thank you for your help. I will give this a try. Unfortunately we are still at Access 2003 but will definitely keep this in mind for the future. So much easier than changing forms all over the place.
Regards Alex
 
Alex,
I think I gave you bad information. I do not have Access on this computer to double check. However, I know you can use a vba function as a default table value. Example in a date field you can create a time stamp
= now()

However, you might not be able to use a User Defined Function (UDF). You will then have to use vba functions for the default value. You may want to test
=Environ("username")
and see if the passes the user name.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top