Solved Insert Into VBA (1 Viewer)

dawsonrhodes

Member
Local time
Today, 05:49
Joined
Mar 8, 2020
Messages
85
Hola,

I'm just making a form that will add users in for a login page, there are two categories of users, employees and management. if a checkbox is clicked before update, the information recorded in the control source tblUsers will be added to tblUsersKey (the exact same collums and setup)

Here is what I have so far

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strSQL As String
If Check154.Value = True Then
If Me.NewRecord Then



'run and hide warnings
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
    
End If
End Sub

The fields are [UserID] (for tblUsers}, [UserIDKey] {for tblUsersKey), [Username], [Password], [FirstName], and [LastName]

Thank you in advance for any help.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:49
Joined
May 7, 2009
Messages
19,234
strSQL = "Insert Into tblUsersKey( UserIDKey, Username, Password, FirstName, LastName ) " & _
"SELECT " & Me!UserID & ",'" & Me!UserName & "','" & Me!Password & "','" & Me!FirstName & "','" & Me!LastName & "'"
 

dawsonrhodes

Member
Local time
Today, 05:49
Joined
Mar 8, 2020
Messages
85
strSQL = "Insert Into tblUsersKey( UserIDKey, Username, Password, FirstName, LastName ) " & _
"SELECT " & Me!UserID & ",'" & Me!UserName & "','" & Me!Password & "','" & Me!FirstName & "','" & Me!LastName & "'"
As always, a VBA saviour from God above.

Thank you so much!
 

Users who are viewing this thread

Top Bottom