Retrieve User Sign on Name

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
 
G

Guest

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 ?
 
R

Rick B

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
 
G

Graham R Seach

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
 
G

Guest

That works - I did name it the same because the web site said to name it
that...

Thanks
 
G

Guest

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 ?
 
D

Douglas J. Steele

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Current User association 3
Get User Login Name 10
two criteria in DLookup 5
fOSUserName 17
Load event question 4
retreving the network login name in a text box 3
fOSUserName revisited 8
DLookup returns same name 9

Top