User ID

MishkaNanook

Registered User.
Local time
Yesterday, 21:21
Joined
Feb 13, 2014
Messages
16
Hi,

I'm trying to ,on loading a form, have it go to a new record and assign a text box called TxtUser the Environ ("USERNAME") value in order to track the user that has added the record.

From what I understand the Environ ("USERNAME") will use the network user name which is what I'm looking for.

I've tried all kinds of variations of code but have yet to come up with one that will work. and not give me some sort of error.

Any help anyone can provide will be greatly appreciated.

Thanks.:o
 
The following line will assign the user name to the text box called TxtUser
Code:
Me.TxtUser = Environ ("USERNAME")
Edit:
The code would need to be in the code module of the form hosting the text box.
 
I tried that but then it assigns it to the first record in the table and not the new record in the table. I have to get it to a new record first which it doesn't do. Here is what I had

Private Sub Form_Load(Cancel As Integer)
DoCmd.GoToRecord acNewRec
Me.txtUser = Environ("USERNAME")
End Sub

At which time I get the following error:

The expression OnLoad you entered or the event property setting produced the following error: Ambiguous name detected: Form_Load

* The expression may not result in the name of a macro, the name of a user-defined function or [Event Procedure]

* There may have been an error evaluating the function, event or macro.

Thanks.
 

Users who are viewing this thread

Back
Top Bottom