On clicking a button I want to add data in to tables. The first table captures all information specified in the form and works fine. The second table that does not have a recordsource, captures information from the selected form. Pls help, part of the code is specified below.
Code:
Set dbs = OpenDatabase("C:\Documents and Settings\lmunyere.DPSM\My Documents\Submission.mdb")
strSQL = "INSERT INTO Logtable (IdentityNumber, Surname, FirstName, " & _
"Username, Action, Time) SELECT " & Me.IdentityNumber.Value & ", " & _
Me.Surname.Value & ", " & Me.FirstName.Value & ", " & Me.lblCapture.Caption & ", " & _
Me.cmdAdd.Caption & "," & Date & ";"
' Me.IdentityNumber & Me.Surname & Me.FirstName & Me.Username
dbs.Execute (strSQL)
'DoCmd.RunSQL strSQL
On Error Resume Next
DoCmd.GoToRecord , "", acNewRec
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
cmdAdd_Click_Exit:
Exit Sub
cmdAdd_Click_Err:
MsgBox Error$
Resume cmdAdd_Click_Exit
dbs.Close
Comment