Hi everyone, I'm new to these forums, but I'm having a bit of an issue. I'm basically trying to get the coding right on the wherecondition, but can't seem to figure out the correct formatting for using multiple entries. This is being used to make a report that pulls selected addresses by name. List2 is a List box, and the For loop creates data that looks like this: "Bill" OR "Jim" OR "Sandy"
Anyway, here's the code.
Anyway, here's the code.
Code:
Private Sub Command11_Click() On Error GoTo Err_Command11_Click Dim x As Integer Dim y As String Dim z As String Dim stDocName As String z = "" For x = 0 To List2.ListCount - 1 y = List2.Column(0, x) y = """" & y & """" If x = 0 Then z = y Else z = z & " OR " & y End If Next x stDocName = "rptAddresses" DoCmd.OpenReport stDocName, acPreview, , "ccustno='" & z & "'" Exit_Command11_Click: Exit Sub Err_Command11_Click: MsgBox Err.Description Resume Exit_Command11_Click End Sub
Comment