How to copy unbound txt box on form to a currrent record in table

RGSATCOM

New member
Local time
Today, 11:34
Joined
May 18, 2015
Messages
3
I created an unbound text box on a form that automatically pulls the current logged in user by using this:

Private Sub Txtuser_Click()
Me.Txtuser = Environ("Username")

The form grabbs the logged in user with no problems, however, I ultimately want this information to also end up in my table. So the form has three boxes (to keep it simple). The user will type their first name and last name manually on the form which the record source is this "table" where their name goes to the table last name =Field 1 and first name=Field 2 respectively. I want the unbound box from the form to place the logged in user in Field 3 for the current record. Any insight will be appreciated. :confused:
 
Doing that way is not advisable since Username is not reliable. Their are Demo's available in the Samples section. That said, it would be much better to use a DLookup for the user and password and compare against your table.
 
Doing that way is not advisable since Username is not reliable. Their are Demo's available in the Samples section. That said, it would be much better to use a DLookup for the user and password and compare against your table.

I am kinda where you are thinking with this:

Private Sub Txtuser_Click()

Me.Txtuser = Environ("Username")

If (DLookup("TblALLUsers", " (userlogin) = '" & Me.Txtuser & "'")) Then
MsgBox "User needs added to data. Please contact the local CSM", vbOKOnly, "Login Info"

The logged in user name is compared against the TblALLUsers.... and does auto populate on the form... getting it from the form, to the TableUsers (different table) automatically is where I am failing!
 
I'm not going to debate the username thing. I disagree.
Still, here is an example you can modify to suit your needs.
PHP:
Dim strSQL As String    'Log Changed Password to tblLostPassword.
                
strSQL = "INSERT INTO tblLostPassword (lastsignon,userID,pw ) "
strSQL = strSQL & "VALUES (#" & Me.txtlastsignon & "#, '" & Me.txtUserID & "', '" & Me.txtCnfPW & "')"
        CurrentDb.Execute strSQL, dbFailOnError

HTH
 
I will try to modify and test it! Thanks a million for all of your input.
 

Users who are viewing this thread

Back
Top Bottom