JamesW
Well-known Member
- Joined
- Oct 30, 2009
- Messages
- 1,197
Hi there,
I'm trying to set a value in a table based on a multi-select listbox. I have little to no experience of SQL.
I get a Syntax Error - Missing Operator.
Any ideas where I'm going wrong? Complete is a Yes/No field. I have also tried =True but I get the same error.
Cheers,
James
I'm trying to set a value in a table based on a multi-select listbox. I have little to no experience of SQL.
Code:
Private Sub Command2_Click()
Dim str_SQLText As String, _
str_MNVal As String, _
str_RTVal As String
Dim i As Long
With lst_MatSelection
For i = 0 To .ListCount - 1
If .Selected(i) Then
str_RTVal = .Column(1, i)
str_MNVal = .Column(2, i)
str_SQLText = "UPDATE tbl_MaterialData " & _
"SET Complete = YES " & _
"WHERE Material Number = '" & str_MNVal & "' AND " & _
"Request Type = '" & str_RTVal & "'"
DoCmd.RunSQL str_SQLText
End If
Next i
End With
End Sub
I get a Syntax Error - Missing Operator.
Any ideas where I'm going wrong? Complete is a Yes/No field. I have also tried =True but I get the same error.
Cheers,
James