Please help I've written the code below so that when a name is selected in a list (lstName) the code adds a line to a table (tbl_logon_history) to show when someone logged on. However I keep getting an error:
"Syntax error in INSERT INTO statement"
Please can someone tell me what I'm doing wrong as I've re-written the code lots of times and I still get an error.
Thanks in advance for any help.
code:
Dim Table
Dim FldDate
Dim FldStaff
Dim ValDate
Dim ValStaff
Dim SQL
Table = "tbl_Logon_History"
FldDate = "Date_Time"
FldStaff = "Staff_Member"
ValDate = Now
ValStaff = lstName.Value
SQL = "INSERT INTO Table ( FldDate, FldStaff ) SELECT ( ValDate , ValStaff );"
DoCmd.RunSQL SQL
"Syntax error in INSERT INTO statement"
Please can someone tell me what I'm doing wrong as I've re-written the code lots of times and I still get an error.
Thanks in advance for any help.
code:
Dim Table
Dim FldDate
Dim FldStaff
Dim ValDate
Dim ValStaff
Dim SQL
Table = "tbl_Logon_History"
FldDate = "Date_Time"
FldStaff = "Staff_Member"
ValDate = Now
ValStaff = lstName.Value
SQL = "INSERT INTO Table ( FldDate, FldStaff ) SELECT ( ValDate , ValStaff );"
DoCmd.RunSQL SQL