Capture Log On

N

Neil Greenough

I have a switchboard. In my switchboard, I would like to display the users
log-on ID for Windows.

So, I want a little text bit that says "You are logged on as XYZ"

Any idea how I would go about this? I know I need to capture the log on ID
from the system somehow, but any ideas? Also, I'm a little dim as to this
and so a step-by-step guide, along the lines of "Create an unbound field and
add the following VB code behind it....." will suffice :)

Thanks once again :)
 
N

Neil Greenough

I have used this code and pasted it into a new module. How do I now get my
form to get the data from this module. On my form, I want something saying
"Please ensure you are ..........(User ID from module)"

How do i link the info from the module to my form?
 
N

Neil Greenough

Lynn,

Can you just tell me how to call the function? So, for example, my module is
called NEW1. How do I call it in the unbound text box?

Thanks
 
J

Jeff Conrad

in message:
Can you just tell me how to call the function? So, for example, my module is
called NEW1. How do I call it in the unbound text box?

On the Default Value (on Properties list) just enter this:

fOSUserName()

When the form opens it will show the current logged on Windows
user name. I would also set the text box to be locked and not enabled.
 
N

Neil Greenough

I am getting the following in the text box, #Name?

Any idea why? I have done as you said Jeff, and my module is called
fOSUserName()
 
N

Neil Greenough

Cheers both Lynn and Jeff.

I am getting #NAME in my unbound text box. Is this simply because I am
working at home and so, I am not working on a networked computer?

Many thanks again
 
J

Jeff Conrad

"Neil Greenough" wrote in message:
I am getting the following in the text box, #Name?

Any idea why? I have done as you said Jeff, and my module is called
fOSUserName()

Any module name cannot be the same as any procedure or function
name because Access goes, "Dude, what's up? I'm confused"

Change the module name itself to modUserName or basUserName
to eliminate confusion.

Here are some links on naming conventions which you may find helpful:

http://www.ltcomputerdesigns.com/JCReferences.html#NamingConventions

Compile the code and then test. All should be good.
 
D

Douglas J. Steele

You don't need to be on a networked computer for that API call to work.

I think Jeff nailed it: if you named the module the same as the function, it
isn't going to work.
 
J

John Vinson

I am getting #NAME in my unbound text box. Is this simply because I am
working at home and so, I am not working on a networked computer?

Set the Control Source property of the textbox to

=fOSUserName()

The = sign is necessary.

John W. Vinson[MVP]
 
N

Neil Greenough

FANTASTIC!

All works now! Changed name of module as recommended. Wasn't sure about this
as was wondering how it would link the two different names together :)
 
Top