leslieinva
asked on
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?
ComputerName returns the Device ID
User Name returns the Windows logged on User Name
mx
User Name returns the Windows logged on User Name
mx
ASKER
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!
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!
You need the equals sign
=ENVIRON("UserName")
it works ... I use it all the time.
mx
=ENVIRON("UserName")
it works ... I use it all the time.
mx
ASKER
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?
Are you using Access 2007?
"
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
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
ASKER
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.
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
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
ASKER
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.
?ENVIRON("UserName") worked in the immediate window! Wonder why not as a default value.
I'm pretty sure this is a Reference issue.
What happens if you do (menu) Debug>>Compile?
mx
What happens if you do (menu) Debug>>Compile?
mx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
btw ... it's the same issue in A2003 ... I totally forgot about that special case.
mx
mx
ASKER
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.
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
mx
"I found the answer myself. "
And the answer is ?
And the answer is ?
ASKER
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.
http://office.microsoft.com/en-us/access/HA012301901033.aspx
I had to edit the registry in order to use Environ at all.
"Access 2007 has a new "feature" sandbox blocking. "
This 'feature' is not new. It surfaced just prior to the release of A2003.
mx
This 'feature' is not new. It surfaced just prior to the release of A2003.
mx
ENVIRON("UserName")
Computer Name
ENVIRON("ComputerName")
mx