I've run into a problem with using a variable in a SQL Update Query in Access 2016. I have a logic field that will get updated based on a previously defined logic.
In this example, Package_Status is a Yes/No logic field in TableName.
This works:
strSQL ="UPDATE TableName SET [Package_Status] = TRUE"
dbName.Execute strSQL
This does NOT work:
xlogic = True
strSQL = "UPDATE TableName SET [Package_Status] = '" & xlogic & "'"
dbName.Execute strSQL
I'm sure the reason is obvious but I'm stumped! Why doesn't the second example work?
The way out of such misery is to print out what you build:
That will reveal why:
Alternatively, when concatenating SQL, you can use my CSql function: