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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate field with username 2

Status
Not open for further replies.

Leaner79

Programmer
Jan 17, 2006
25
0
0
BW
Hi,
I would like help with the following.
I have a form that has a userneme field. I want this field to updated with the username of the person logged on to the PC.
This should only update if the form is in Add Mode.

Thanks
 
In the BeforeInsert event procedure of the form:
Me![userneme] = Environ("USERNAME")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Brilliant! I never knew about that one.

Have fun! :eek:)

Alex Middleton
 
Thanx, PHV

That piece of code works perfect.
But can i ask you another question?

I have a switchboard that i use to open my form in either add mode or edit mode..
I only want the above code to work when i am in edit mode..
If i am in add mode, then the username should be saved in a different field.

Thanx
 
Have a look at hte NewRecord property of the Form object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top