?
Solved

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

Posted on 2008-11-12
18
Medium Priority
?
489 Views
Last Modified: 2012-05-05
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?
0
Comment
Question by:leslieinva
  • 11
  • 7
18 Comments
 
LVL 75
ID: 22942792
user name
ENVIRON("UserName")

Computer Name

ENVIRON("ComputerName")

mx
0
 
LVL 75
ID: 22942797
ComputerName returns the Device ID

User Name returns the Windows logged on User Name

mx
0
 

Author Comment

by:leslieinva
ID: 22942958
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
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 
LVL 75
ID: 22943043
You need the equals sign

=ENVIRON("UserName")

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

mx
0
 

Author Comment

by:leslieinva
ID: 22943084
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
 
LVL 75
ID: 22943129
"
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
 

Author Comment

by:leslieinva
ID: 22943215
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
 
LVL 75
ID: 22943244
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
 

Author Comment

by:leslieinva
ID: 22943384
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
 
LVL 75
ID: 22943424
I'm pretty sure this is a Reference issue.

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

mx
0
 

Accepted Solution

by:
leslieinva earned 0 total points
ID: 22943498
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
 
LVL 75
ID: 22943527
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
 
LVL 75
ID: 22943535
btw ... it's the same issue in A2003 ... I totally forgot about that special case.

mx
0
 

Author Comment

by:leslieinva
ID: 22944387
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
 
LVL 75
ID: 22944438
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
 
LVL 75
ID: 22955010
"I found the answer myself. "

And the answer is ?
0
 

Author Comment

by:leslieinva
ID: 22960348
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
 
LVL 75
ID: 22961488
"Access 2007 has a new "feature" sandbox blocking. "

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

mx
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question