Is there a way for Access 2007 to know the machine name of a user who opens the database?

I can put a Microsoft Access 2007 database on a public drive to share with people.  I would like this database to save the name of the user or his PC when he adds or updates a record.  Is there any code I could use to grab the name of the user, his  PC, or any other identifying info that I could then save in a record?
leslieinvaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
user name
ENVIRON("UserName")

Computer Name

ENVIRON("ComputerName")

mx
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
ComputerName returns the Device ID

User Name returns the Windows logged on User Name

mx
0
leslieinvaAuthor Commented:
This looks very useful.  In the table designer, I tried to set a field's Default Value to
ENVIRON("UserName"), but it gave me an Unknow Function message.  How would I set the Default Value in the table desiner using this?  (I know I said I'd use code, but the table desingers Default Value is much easier to use.)

Thanks!
0
The Five Tenets of the Most Secure Backup

Data loss can hit a business in any number of ways. In reality, companies should expect to lose data at some point. The challenge is having a plan to recover from such an event.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
You need the equals sign

=ENVIRON("UserName")

it works ... I use it all the time.

mx
0
leslieinvaAuthor Commented:
I copied what you wrote here, =ENVIRON("UserName") into the Default Vaule of a field I named User_name & I got this error: "Unknown function 'Environ' in validation expression or default value on 'Table1.User_Name."

Are you using Access 2007?
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
"
Are you using Access 2007?"

no.

Open the VBA editor.
Tools>>References.
Be sure a reference is set to Microsoft DAO.xx Object Library

mx
0
leslieinvaAuthor Commented:
I get a weird error message when I try to add the reference: "Name conflicts wit exiting module, project, or object library."  It won't let me add the rerference.
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
humm.  Is that reference already there?

What happens if you do (menu) Debug>>Compile?

Also ... in the Immediate Window ... type

?ENVIRON("UserName")   and Enter  (including the question mark)

what happens?

mx
0
leslieinvaAuthor Commented:
No, the reference isn't there yet & it won't let me add it BUT
?ENVIRON("UserName") worked in the immediate window!  Wonder why not as a default value.
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
I'm pretty sure this is a Reference issue.

What happens if you do (menu) Debug>>Compile?

mx
0
leslieinvaAuthor Commented:
Access 2007 has a new "feature" sandbox blocking.
http://office.microsoft.com/en-us/access/HA012301901033.aspx
I have to edit the registry in order to use Environ, but then I'd guess I'd have to edit all the users' registry?  That pretty much makes it useless as far as I can tell, because I can't edit other people's registries.

Guess we're done unless you have any other ideas.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
It's the bogus Macro Security.

Open Access - any ACCDB or none.

In A2003 ... it's Tools>>Macro>>Security .... set to LOW.

Here are some links that may help you get around that:

http://office.microsoft.com/en-us/access/HA100319991033.aspx#3  'Trusted Locations
http://office.microsoft.com/en-us/access/HA102564121033.aspx  'Trusted DB
http://www.mac-net.com/1159484.page       'Not possible to determine ....

http://msdn2.microsoft.com/en-us/library/bb421308.aspx  'A2007 Macro Security

mx
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
btw ... it's the same issue in A2003 ... I totally forgot about that special case.

mx
0
leslieinvaAuthor Commented:
Doesn't work in 2007.  I already have macro security set "Enable all macros"  None of the "trust" related stuff makes any difference.  It's the sandbox thing wiht 2007.
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Well, since I don't have A2007 loaded, I can't experiment.  I've have run into the exact same issue in A2003 - until I set Macro (in)Security to Low.

mx
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
"I found the answer myself. "

And the answer is ?
0
leslieinvaAuthor Commented:
Access 2007 has a new "feature" sandbox blocking.
http://office.microsoft.com/en-us/access/HA012301901033.aspx
I had to edit the registry in order to use Environ at all.
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
"Access 2007 has a new "feature" sandbox blocking. "

This 'feature' is not new.  It surfaced just prior to the release of A2003.

mx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.