AutoMate
AutoMate

Reputation: 71

Is my query and use of apostrophes right?

Trying to get this query right where it takes in variables to update the records. I tried playing around with the quotation marks and either I would get "Enter a parameter value" dialogue screen or "Syntax error (Missing Operator)" error.

updateOriginalBudget_SQL = "UPDATE SubPhases SET OriginalBudget=" & matchBudget & " " & "WHERE ShopCode=" & elemShopCode & ";"
DoCmd.RunSQL updateOriginalBudget_SQL

matchBudget is an integer and elemShopCode is a String. If I just write a simple query like:

"UPDATE SubPhases SET OriginalBudget=5 WHERE ShopCode='344S-23';"

it'll work with no issues. Any idea what I am doing wrong here?

Upvotes: 0

Views: 62

Answers (1)

Louis
Louis

Reputation: 3632

In the original query, you're missing the quotes '' for field values. In your ShopCode you have a value with - which is an operator and that's why you're getting a "Syntax error (Missing Operator)" error.

Change the query like this and it will work:

updateOriginalBudget_SQL = "UPDATE SubPhases SET OriginalBudget=" & matchBudget & " WHERE ShopCode='" & elemShopCode & "';"

I hope this helps.

Upvotes: 1

Related Questions