use network logon id to set default value for a field

  • Thread starter Thread starter Russ Kunkel
  • Start date Start date
R

Russ Kunkel

How can I (or can I) check to see who is logged on and use
the value to set the default value for a form field?
 
There's code to retrieve the network user name at the following URL ...

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

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Brendan

I tried the code and I get nothing.

-----Original Message-----
There's code to retrieve the network user name at the following URL ...

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

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E- mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e- mail, you'll find
a useable e-mail address at the URL above.





.
 
Works great .. thanks much.

-----Original Message-----
There's code to retrieve the network user name at the following URL ...

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

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E- mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e- mail, you'll find
a useable e-mail address at the URL above.





.
 
Russ or Brendan or Anyone,

Could you be a little more detailed about how to set this up. I
pasted the code in a new module. I don't understand what's next with
'call the function fOSUserName'. What does that mean? What name do I
call the new module? How do I set up the text box in my form?

I'm new at most of this, but having fun learning more and more.
Thanks for your help!!
 
Something like the following should do it, probably in the Load event of the
form ...

Dim strTheUser As String

strTheUser = fOSUserName()
Select Case strTheUser
Case "FirstUserNameHere"
Me!NameOfTextBoxHere.DefaultValue = Chr$(34) &
"FirstUsersDefaultValueHere" & Chr$(34)
Case "SecondUserNameHere"
Me!NameOfTextBoxHere.DefaultValue = Chr$(34) &
"SecondUsersDefaultValueHere" & Chr$(34)
Case Else
Me!NameOfTextBoxHere.DefaultValue = Chr$(34) &
"DefaultValueForAllOtherUsersHere" & Chr$(34)
End Select

It doesn't matter what you call the module.

Chr$(34) returns a double quote character (34 is the ASCII code for the
double quote character). The default value property expects a string
enclosed in double quotes, and I find using the Chr$() function like this
easier than trying to embed quotes within quotes.

You can probably see from the example above that assigning default values
based on individual user names is only going to be practical while there are
a small number of users. You wouldn't want to write, or maintain, code like
this with hundreds, or even dozens, of users.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Back
Top