Link to home
Start Free TrialLog in
Avatar of stephenlecomptejr
stephenlecomptejrFlag for United States of America

asked on

Need help with run time error 3075 - syntax error for SQL Statement.

Need help with identifying syntax error:

Here's the output of SQL string:

DELETE tempTimesheetWeek.PMHours, tempTimesheetWeek.AMHours, tempTimesheetWeek.[08WorkDate], tempTimesheetWeek.[01WorkDate] FROM tempTimesheetWeek WHERE (tempTimesheetWeek.PMHours = 0 Or tempTimesheetWeek.PMHours IsNull)  AND tempTimesheetWeek.AMHours >0 AND tempTimesheetWeek.[01WorkDate] = #12/13/2018#

Open in new window


Please note image of syntax error message
sql-syntax-msg.PNG
ASKER CERTIFIED SOLUTION
Avatar of bfuchs
bfuchs
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Simplify it:

DELETE FROM tempTimesheetWeek
WHERE Nz(PMHours, 0) = 0 AND AMHours > 0 AND [01WorkDate] = #12/13/2018#;

Open in new window

Just to be clear, you cannot delete specific fields in a table. You delete ROWS, i.e. the entire row.
Other than that, I would stick to using Is Null, which is plan SQL and doesn't involving function calls. It is faster.

DELETE FROM tempTimesheetWeek WHERE (tempTimesheetWeek.PMHours = 0 Or tempTimesheetWeek.PMHours Is Null)  AND tempTimesheetWeek.AMHours >0 AND tempTimesheetWeek.[01WorkDate] = #12/13/2018#

Open in new window

Avatar of stephenlecomptejr

ASKER

Appreciate everyone's replies.  Thanks for the help!