I have a WHERE clause that seems to be being ignored. Here are the particulars. I have a multiselect listbox on a form. User selects clients and clicks a command button cmdRemoveClients. The code behind the command button does this stuff:
Private Sub cmdRemoveClients_Click()
Dim strSQL As String ‘holds the delete query string
‘confirm the update here…
””””””””””””””””
If MsgBox(“You are about to remove clients ” & SelectedClients() & ” from the mailing list.”, vbYesNo, “Confirm Delete”) = vbYes Then
strSQL = ” DELETE ClientNoMatch.*, ClientNoMatch.[Client No] ” & _
” FROM ClientNoMatch ” & _
” WHERE SelectedClients() ” & _
” WITH OWNERACCESS OPTION; ”
DoCmd.RunSQL strSQL
Else
‘user chooses not to remove clients…
Exit Sub
End If
End Sub
SelectedClients() is a function that takes the selections in the multiselect listbox and generates a string that looks exactly like this:
“(((ClientNoMatch.[Client No]) = “11128” Or (ClientNoMatch.[Client No]) = “11134”))”
When I click the “Remove Clients” button, the delete query prompts me with the warning message that says “You are about to delete 408 records…. ” 408 records are all of the records in the ClientNoMatch table.
Therefore, I conclude that the SQL Statement is ignoring the WHERE clause that identifies the 2 clients I wish to remove. So, the question is, what do I need to do to the WHERE clause to make it work?
Thanks in advance.