Retrieve User Sign on Name

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

Guest

I am trying to have the Name Field in my form auto fill in based on who's
signed on to the Network. I followed the instructions I was given to follow
at this web site but I get a error "Name" displayed in my form's Name Field.

http://www.mvps.org/access/api/api0008.htm

I copied and pasted the code in a new module and called the function
fOSUserName. Then I opened my Name Field properties in my form and inserted
the module name as the default value anf I get the error message, What am I
doing wrong ?

Thanks - George
 
Still get #Name?

I inserted =fOSUserName()
in the "Control Source" field - no help
I inserted =fOSUserName() in the
"Default Value Field" - no Help

What else can I try ?
 
What did you name your module? It can;t be named the same as the function.
Change the name of it if you used FOSUSERNAME.

Rick B
 
Just tested it - works fine for me with the following in the TextBox's
DefaultValue property:
=fOSUserName()

Try this:
In the form's Current() event, add the following code (change the
TextBox name to reflect the name you have).
Me!txtMyTextBox = fOSUserName()

If that doesn't work, go to any code module. Select [Immediate Window] from
the View menu. Then in the Immediate Window, enter:
?fOSUserName
....then hit the Enter key.

If that doesn't work, select Compile from the Debug menu, and fix whatever
error is displayed. Repeat this process until no more errors are reported.

If still no joy, are you on Windows 98?

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Graham - I changed the name of the module like Rick said and then used it in
the DefaultValue field as you mentioned and it works. Thanks for your time...

Graham R Seach said:
Just tested it - works fine for me with the following in the TextBox's
DefaultValue property:
=fOSUserName()

Try this:
In the form's Current() event, add the following code (change the
TextBox name to reflect the name you have).
Me!txtMyTextBox = fOSUserName()

If that doesn't work, go to any code module. Select [Immediate Window] from
the View menu. Then in the Immediate Window, enter:
?fOSUserName
....then hit the Enter key.

If that doesn't work, select Compile from the Debug menu, and fix whatever
error is displayed. Repeat this process until no more errors are reported.

If still no joy, are you on Windows 98?

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html


George said:
Still get #Name?

I inserted =fOSUserName()
in the "Control Source" field - no help
I inserted =fOSUserName() in the
"Default Value Field" - no Help

What else can I try ?
 
Actually, the page doesn't say to name the module anything specific: it says
"Paste the following code in a new module and call the function
fOSUserName." In other words, it's saying that once you've saved the code in
a module, you can call the function fOSUserName to get the user name. I
suppose I understand how you might have misinterpretted that, though.
 
Back
Top