Set a Field's Default Value as Windows User Name (1 Viewer)

JithuAccess

Member
Local time
Today, 15:16
Joined
Mar 3, 2020
Messages
297
Hello Guys,

I have a field "Data Entry By" and there are 10 Staffs using the database. Is it possible, to set the default value of "Data Entry By" field as Windows User Name?

For Example, if a user ABC123 is using the Form for Data Entry, in the Table, I want to display ABC123 as "Data Entry By". I will not be showing "Data Entry By" in the Form. We are using Windows10 Enterprise

Is it possible.
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:16
Joined
Sep 21, 2011
Messages
14,238
Look at the Environ() function for the simplest, if not the most secure way.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 17:16
Joined
Feb 19, 2002
Messages
43,233
Most of my tables have three tracking fields - CreateDT, LastChangeDT, ChangeBy.

CreateDT is set to default to Now() in the field description of the table.

The other two are always set in the Form's BeforeUpdate event.

Me.LastChangeDT = Now()
Me.ChangeBy = Environ("UserName") ---- or some API or other alternative.

I do display these fields on the last line of the form unless it is just too full. If you do, make sure to set TabStop to No and locked to Yes to avoid tampering.
 

Users who are viewing this thread

Top Bottom