Access Macro to check the Environ("UserName")

pavin

Active Member
Joined
Jan 20, 2009
Messages
308
Hi All,

I have a requirement where I need to use the Access Macro to check for the username who opened the database. I know how to use it in VBA module, but was trying the same in Macro wizard and it isn't working. Request for help. Thank you.

I used

if Environ("UserName") = "xxxx" then


Note, I need it only in the Macro and not in VBA module. Thank you
 
Last edited:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I tried Environ() in a Macro in 2010 and it did not like it.

I was able to do this:

1) in the startup run this line of VBA code:

TempVars.Add "UserName", Environ("UserName")


2) In the macro you can use:

If TempVars]![Username] = "xxx" Then
 
Upvote 0

Forum statistics

Threads
1,216,067
Messages
6,128,590
Members
449,461
Latest member
jaxstraww1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top