Application.Username and environ("Username")

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
How can i get Application.Username and not environ("Username") in access databse vba code?

Thanks!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hi

Whereabouts do you set the user name through the Access interface? Access is different to Excel in that you don't really save Access files but only the objects within so I don't if the username would be useful. I had a quick look through Options in Access 2003 and could not see a "Username" field anywhere.

DK
 
Upvote 0
Hi

Whereabouts do you set the user name through the Access interface? Access is different to Excel in that you don't really save Access files but only the objects within so I don't if the username would be useful. I had a quick look through Options in Access 2003 and could not see a "Username" field anywhere.

DK

Thanks for replying...
When i go to access tools >> Popular >> username = Pedie Nz

I want to get that.

Thanks again.
 
Upvote 0
If you are using Access User Level Security then you can use

CurrentUser()

to return the logged in user.
 
Upvote 0
Hi Bob, it returned admin...whereas i want the actual name that appears in the popular tab >> user name field in access tools:)

Thanks again for helping..
 
Upvote 0
this assumes the user has excel installed
it also assumes that the name the user entered as the "licensed user" for excel is the same as the one in access

I'm sure the code has problems (aside from the ones made by the assumptions)
I never was very good with createobject vs getobject and all the error handling that goes with them

but this works (on my computer anyway)

Code:
Sub xxx()

    Dim xl As Object
On Error Resume Next
    Set xl = CreateObject("excel.application")
    MsgBox xl.UserName
    Err.Clear
On Error GoTo 0
    Set xl = Nothing

End Sub
 
Upvote 0
Thanks James....since there is way without connecting to Excel... this is perfect...Appriciate your help...

Have a great weekend guys!!! Thanks all...
Thanks Bob
 
Upvote 0
Without the unnecessary variable xl:

Code:
Sub xxx()
    On Error Resume Next
    MsgBox CreateObject("excel.application").UserName
    On Error GoTo 0
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,314
Members
452,905
Latest member
deadwings

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