Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax Error (missing operator) 1

Status
Not open for further replies.

DYM03

Technical User
Mar 6, 2003
28
US
I keep getting a Syntax Error in the code below but I cannot figure out what is missing. Please help!


db1.Execute "SELECT EmployeeTime " _
& "WHERE [EMPLOYEE_NAME] = '" & [EmpName] & "';"
 
I didn't paste it all, sorry. But I finally figured out the syntax error. Now I a message saying that I cannot execute a select clause but I need to pull specific records in the recordset. How would I use the select clause or select specific records. I have posted my code below.

Set rstEmployees = db1.OpenRecordset("EmployeeTime", dbOpenDynaset)

db1.Execute "SELECT * FROM EmployeeTime WHERE [EMPLOYEE_NAME] = '" & [EmpName] & "';"

db1.Execute "UPDATE EmployeeTime SET [EMPLOYEE_NAME] = '" & [EmpName] & "', [PERFROM] = '" & [PerFrom] & " ', [PERTO] = '" & [PerTo] & " ', [REG] = '" & [Reg] & "', [OTP] = '" & [Otp] & "', [VAC] = '" & [Vac] & " ', [SCK] = '" & [Sck] & "', [HOL] = '" & [Hol] & "', [LWO] = '" & [Lwo] & "', [LWP] = '" & [Lwp] & "', [TOTAL] = '" & [Total] & "';"

db1.Close

MsgBox EmpName & " Has been updated", vbOKOnly
 
Hi DYM03,

What is the purpose of the SELECT? Are you just trying to specify which records to update? If so, all you need to do is add a WHERE clause to your UPDATE ..

db1.Execute "UPDATE EmployeeTime SET ... & [Total] & "' WHERE [EMPLOYEE_NAME] = '" & [EmpName] & "';"

Enjoy,
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top