niki
axes noob 'll b big 1 day
- Local time
- Today, 23:01
- Joined
- Apr 17, 2003
- Messages
- 66
Filter using VB
Hello! I use Access 2002
I found this code on the microsoft support site. I tried to use it with my own tables. So I changed the names of the reports and the tables they were refering to in a clean manner. This code is the code of an action button which takes the values from three comboboxes and filters the data shown on a report.
When I try to use these filters, I get the correct values on the drop down list but when I push the go button, Access tells me I'm missing an operator, so I believe there's a syntax error somewhere.
Apparently, this code stores the value chosen in my filters. Could someone explain to me quickly these code lines???
Thx
nico
here's an explanation but its still not clear to me...
http://support.microsoft.com/default.aspx?scid=kb;en-us;208529
Hello! I use Access 2002
I found this code on the microsoft support site. I tried to use it with my own tables. So I changed the names of the reports and the tables they were refering to in a clean manner. This code is the code of an action button which takes the values from three comboboxes and filters the data shown on a report.
When I try to use these filters, I get the correct values on the drop down list but when I push the go button, Access tells me I'm missing an operator, so I believe there's a syntax error somewhere.
Apparently, this code stores the value chosen in my filters. Could someone explain to me quickly these code lines???
Thx
nico
here's an explanation but its still not clear to me...
http://support.microsoft.com/default.aspx?scid=kb;en-us;208529
Code:
Private Sub Command28_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
'Strip Last " And "
strSQL = left(strSQL, (Len(strSQL) - 3))
'Set the Filter property
Reports![rptCustomers].Filter = strSQL
Reports![rptCustomers].FilterOn = True
Else
Reports![rptCustomers].FilterOn = False
End If
End Sub
Last edited: