login user id code

M

Myron Mummey

I read many threads regarding using the code found at this web site:
http://www.mvps.org/access/api/api0008.htm
After testing it in a seperate DB several differnt ways, I found it works
just as it says but I wanted to help explain it a little.

Copy the code from the web site and paste it into a new module and name it
as the web site explains. Be sure to compile it before you close it and make
sure you save any changes!! I found two type O's.

After that add a text box to your form. In the text properties call the
function usinf =fousername, the same name you gave the module, and place this
call in both the control source and default vale of the text box properties.
I don't know why you have to have it in both but I couldn't get it to work
anyother way!!

After that open the form in form view and your name or the name of the
logged in person should appear!! Now, depending on your network and IT
support, some users may get errors if their version of access and all its
patches are not up to date, but that is an easy fix!! Best of luck!!
Myron
 
K

Krizhek

I love the code mentioned above. But furthur insite to the comments listed is
needed.

You can place the function =fOSUserName() in either the control field or the
default field.

I imagine Myron's problem may have come from creating a text box to the form
and adding =fOSUserName() to the default field and going back to form view
(without reopening the form). Which would cause the text box to remain
empty. Default only runs when the form opens and not between switching
views. While control will update if you happen to change from design view
and then back to normal view and to boot it will keep the field from being
edited.

Either will work fine but keep in mind that if you use default and leave all
the other controls for that text box at the default the user can change the
login name(which defeats the purpose for me using it).
 
D

Douglas J Steele

I'm unaware of any typos in that code.

If you think you found two, would you care to share them?
 
M

Myron Mummey

Doug and Krizhek,

First Krizhek, you are precise my dear Watson!! When I wrote this yesterday
I had not forseen that problem unitl I applied it again in another form.
Thanks for picking that up for me. As for users changing the name, that I
don't mind, we are using it as an added automatic feature for our users, its
not really for accountability or anything, just a nicety.

Doug, the two errors the debugger found were a double end sub and an
apostrophe that was missing causing a comment to throw ot off. It very well
could have beena copy and paste error on my part. I definately would never
come down on the code or its creator, I love the fact that it works!! It
gave the boss what he wanted and made me look like a momentary God!! Short
lived until this morning when he wants all new stuff!! LOL!! Always wanting
more!! Thanks for all your help, I look forward taking more of your advice
down the road!!

Myron
 
Top