SQL statement help re: missing operator

CBG2112

Registered User.
Local time
Today, 01:20
Joined
Aug 4, 2009
Messages
32
Please help with the following SQL statement below. When I try to run the statement, the error message, "Syntax error (missing operator ) in query expression "QC'd - Okay' WHERE [BATCH_ID]=9807', appears. I can't figure out what's missing or incorrect. Thanks.

Code:
    cboStatus.SetFocus
    strSQL = "UPDATE tblBatches " & _
                "SET [STATUS_TX]='" & Me.cboStatus.Text & "' " & _
                "WHERE [BATCH_ID]=" & Me.BATCH_ID.Value
    DoCmd.RunSQL strSQL
 
The error lies here

"QC'd - Okay'

It's the apostophe in QC'd

Change

"SET [STATUS_TX]='" & Me.cboStatus.Text & "' " & _

To

"SET [STATUS_TX]=" & Chr(34) & Me.cboStatus & Chr(34) & " " & _
 
Also, you should avoid using .TEXT so you don't need to set focus on stuff. If you want the text displayed by a combo box which has a bound column of an ID number and displays the text then you would simply need to use:
Code:
    Me.cboStatus.Column(1)
Where Column(1) is the second column (combo columns in this context are zero-based)
 

Users who are viewing this thread

Back
Top Bottom