Hi:
I created a tblLog to tract the users which has "Username"(captured
NetID) and "Date"(=now).
I created a frmSwitchboard bounds to tblLog and add the "txtUsername"
and "txtDate". I got an error using the codes below "Syntax error in
INSERT INTO statement". I'm a beginner and don't know how to properly
execute a query. Thanks.
Private Sub Form_Close()
Dim stDocName As String
Dim strSQL As String
strSQL = "INSERT INTO tblLog (Username,Date) VALUES ('" &
txtUserName & "', '" & txtDate & "');"
stDocName = "Switchboard"
If Me.txtCountUserName.Value = 0 Then
DoCmd.OpenForm "frmUnauthorizedUser"
Else
CurrentDb.Execute strSQL
DoCmd.OpenForm stDocName
End If
End Sub
Ronald Roberts - 16 Jul 2005 07:10 GMT
The date needs # signs around it, not quotes.
Try using Date() and not Now().
Date is a reserved word, I wouldn't use it as a field name.
strSQL = "INSERT INTO tblLog (Log_Username, Log_Date) VALUES ('" &
txtUserName & "', #" & txtDate & "#);"
Ron
> Hi:
>
[quoted text clipped - 23 lines]
>
> End Sub
Jologs - 16 Jul 2005 08:37 GMT