Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default User Name in Access 2003

Status
Not open for further replies.

dannyb29

Technical User
Nov 10, 2010
90
GB
Just as you can add a date stamp in Acess I would like to add a Username stamp.
One of the fields on my form is allocated to the user so it would save a lot of time if this field was automatically populated by either the Log On name or NT user name.
I am using Access 2003 can anyone be of assistance?

Many Thanks
 
Try the Environ("Username") function in the default value of your table field
 
Try the Environ("Username") function in the default value of your table field
It won't work there. You need to use it as a default on a CONTROL's default on a FORM. You can't set many functions as default at field level in a table (Date() or Now() are two that you can do). So you have to put them as default on the form control instead.

Bob Larson
FORMER Microsoft Access MVP (2008-2009, 2009-2010)
Free Tutorials/Samples/Tools:
 
Duane
Thanks for your link, I have been looking for a suitable alternative to the Environ function myself and I will now switch to your suggestion option.

Bob: I disagree, you can set the field default in a table by using the Environ function in A97 and A2003, however, I have had to strip it out in A2007 so now I can happily use Duane's suggestion. Goods news all round on this post!
 
Thank you for all your help guys, i'm sorry to say Duane but how do i connect this to a field within my form. I am a bit of a novice when it comes to modules. I think i replace one of the references with my textbox name? Is that correct?
 
Dannyb29,
Create a new, blank Module and paste the code from the web page. Save the module with a name like "modAPIs". You can then set the Default Value property of the text box to:

=fOSUserName()

Duane
Hook'D on Access
MS Access MVP
 
Thank you guys!! Thats the best help ever and it works!! X
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top