Avatar of stephenlecomptejr
stephenlecomptejr
Flag 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
Microsoft AccessVBA

Avatar of undefined
Last Comment
stephenlecomptejr

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
bfuchs

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ste5an

Simplify it:

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

Open in new window

Anders Ebro (Microsoft MVP)

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

stephenlecomptejr

ASKER
Appreciate everyone's replies.  Thanks for the help!
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy