Hi,
I have a query that I use to export data to a spreadsheet. The query itself works fine and I can manually edit the query to supply filtered information. What I would like to do is use a form that has several filter options so I do not have to modify my query every time I run it. I have a form with a list box to define one of the filters and I can make it work with that specific filter using the DoCmd.ApplyFilt er function. I want/need to add at least one more list box and possibly a couple of pick lists to create additional filter options.
The background for this is that the query gives me a subset of data with geographic coordinates that I import into a mapping application (MapPoint). I use this to analyze event locations based on changing criteria, such as Time of day and Day of week. Here is the code that I use in the form for the one filter that works:
[VB Code]...
Private Sub GeoReport_Click ()
Dim strFilter1 As String
Dim varItem As Variant
Dim intCount As Integer
For Each varItem In Me!List2.ItemsS elected
strFilter1 = strFilter1 & "[LEV3] = '" & _
Me![List2].ItemData(varIt em) & "' OR "
Next
' continue loop
'
' the next bit of code will subtract out the last "OR"
If strFilter1 <> "" Then
strFilter1 = Left(strFilter1 , Len(strFilter1) - 4)
For intCount = 1 To List2.ListCount
List2.Selected( intCount) = True
Next
Else
MsgBox "You did not select any zones!"
List2.SetFocus
Exit Sub
End If
'
' now, run the report using strFilter to pass a string
' containing the needed employees
DoCmd.OpenQuery "qry_GeoEventLo cation"
DoCmd.ApplyFilt er , strFilter1
End Sub
...[/End VB Code]
I have tried to incorporate additional string variables for additional list boxes (which is why you see the "strFilter1 ") without success. Any thoughts on how to attack this?
Thanks!
I have a query that I use to export data to a spreadsheet. The query itself works fine and I can manually edit the query to supply filtered information. What I would like to do is use a form that has several filter options so I do not have to modify my query every time I run it. I have a form with a list box to define one of the filters and I can make it work with that specific filter using the DoCmd.ApplyFilt er function. I want/need to add at least one more list box and possibly a couple of pick lists to create additional filter options.
The background for this is that the query gives me a subset of data with geographic coordinates that I import into a mapping application (MapPoint). I use this to analyze event locations based on changing criteria, such as Time of day and Day of week. Here is the code that I use in the form for the one filter that works:
[VB Code]...
Private Sub GeoReport_Click ()
Dim strFilter1 As String
Dim varItem As Variant
Dim intCount As Integer
For Each varItem In Me!List2.ItemsS elected
strFilter1 = strFilter1 & "[LEV3] = '" & _
Me![List2].ItemData(varIt em) & "' OR "
Next
' continue loop
'
' the next bit of code will subtract out the last "OR"
If strFilter1 <> "" Then
strFilter1 = Left(strFilter1 , Len(strFilter1) - 4)
For intCount = 1 To List2.ListCount
List2.Selected( intCount) = True
Next
Else
MsgBox "You did not select any zones!"
List2.SetFocus
Exit Sub
End If
'
' now, run the report using strFilter to pass a string
' containing the needed employees
DoCmd.OpenQuery "qry_GeoEventLo cation"
DoCmd.ApplyFilt er , strFilter1
End Sub
...[/End VB Code]
I have tried to incorporate additional string variables for additional list boxes (which is why you see the "strFilter1 ") without success. Any thoughts on how to attack this?
Thanks!
Comment