I am using a pop-up form to filter a report. The code I am using comes from the Microsoft site. Have used it before, and it works perfectly. Until now. This is the code to set the filter choices:
Private Sub Set_Filter_Click()
Dim strSQL As String, intCounter As Integer
' Build SQL String.
For intCounter = 1 To 3
If Me("Filter" & intCounter) <> "" Then
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " & " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
End If
Next
If strSQL <> "" Then
' StripLast " And ".
strSQL = Left(strSQL, (Len(strSQL) - 5))
' Set the Filter property.
Reports![SubcontractorPhonebook].Filter = strSQL
Reports![SubcontractorPhonebook].FilterOn = True
End If
End Sub
When I press the "set filter" button which should run this code, I get an error stating:
"Compile Error: Can't Find Project or Library" and it is highlighting the 'Chr' in the fifth line of the code. Can anyone tell me why and what I can do to make this work?
Thank you in advance. I appreciate any help.
Dianne in VA
Private Sub Set_Filter_Click()
Dim strSQL As String, intCounter As Integer
' Build SQL String.
For intCounter = 1 To 3
If Me("Filter" & intCounter) <> "" Then
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " & " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
End If
Next
If strSQL <> "" Then
' StripLast " And ".
strSQL = Left(strSQL, (Len(strSQL) - 5))
' Set the Filter property.
Reports![SubcontractorPhonebook].Filter = strSQL
Reports![SubcontractorPhonebook].FilterOn = True
End If
End Sub
When I press the "set filter" button which should run this code, I get an error stating:
"Compile Error: Can't Find Project or Library" and it is highlighting the 'Chr' in the fifth line of the code. Can anyone tell me why and what I can do to make this work?
Thank you in advance. I appreciate any help.
Dianne in VA