autofill values for logged in users

matt.w.stevens

New member
Local time
Today, 03:16
Joined
Jul 19, 2019
Messages
5
Hello. I have created a database for a minimum of ten users to log into simultaneously and add records via a form. All of the records need to have the respective usernames appended to the records to show they were the ones entering the data.

How do I get access to do this? Do I really need to make a list of users and have them select themselves from a dropdown? Is there a way to get the form to display the user who is currently logged in?

Thanks in advance.
 
Logged into Windows? Try Environ("username").
 
you need to Split the db (Fe-Be).
the front-end is given to each users.
then you can use:

environ("UserName")

to show the name of the user.
add the field, where the username will be save, to the form.
then make the Visible Property of the textbox to No.
also you add code to the BeforeUpdate event of your form, to add the UserName.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me![textBoxForUserName] = Environ("UserName")
End Sub
 
Putting that as a default value in the table's field's Default Value parameter returns an error message. "Unknown function 'Environ' in validation expression or default value on (field name)"
 
don't put it on Default value, coz it's not on the list of built-in function.
use the Form's BeforeUpdate event.
 
don't put it on Default value, coz it's not on the list of built-in function.
use the Form's BeforeUpdate event.

Okay. I am using Access 2016 if that makes any difference. I've split the DB as well.

Entering


Private Sub Form_BeforeUpdate(Cancel As Integer)
Me![techid] = Environ("UserName")
End Sub

into before update gives me an invalid syntax error.
 
I just tested this and it worked fine. I used the name of a textbox bound to a field in the table:

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
  Me.Text16 = Environ("username")
End Sub
 
what datatype is TechID, string or numeric.
is it on the form?
 
I just tested this and it worked fine. I used the name of a textbox bound to a field in the table:

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
  Me.Text16 = Environ("username")
End Sub

Am I supposed to be entering this in the field's expression builder? It gives me three choices. Expression, code, and macro.
 
what datatype is TechID, string or numeric.
is it on the form?

techid is all lowercase. It's a short text data type. Display Control is Text Box.

It appears on the form as a blank text box when not in design mode.
 
on design view of your form, on its Property Sheet->Event->Before Update.
you choose code from the selection.
 

Users who are viewing this thread

Back
Top Bottom