Cannot retrieve the UserName in MS Access?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using Windows XP and Access 2003. How can I retrieve the UserName within
my Access code? I have tried [UserName], but that always returns a null
value. I've also tried (following one of the replies on here) to set the
control source of a text box on a form to [=fOSUserName()], but that returns
the error message #Name?

All I want to do is to ensure that my database code is user-specific (ie
certain code will run or not depending on who the user is).

Thanks

Alex
 
Your use of =fOSUserName() implies to me that you're trying to use the code
from http://www.mvps.org/access/api/api0008.htm at "The Access Web".

When you copied that code into a module, did you copy everything between the
Code Start and Code End lines? What did you name the module? If you named it
fOSUserName, that's your problem: modules cannot be named the same as subs
or functions.

Do you actually have the square brackets around the reference to the
function in the text box's ControlSource property? If so, get rid of them:
all you want is =fOSUserName.
 
Back
Top