I'm attempting to create a form called Filtered Form that has 3 list boxes. These list boxes can either be used or not in any combination. I would like the results in the unselected list boxes to filter when another is updated.
I would like the results of a subform named Child1 to list the filtered results of the 3 list boxes. When none are selected, all records show and when selections are made the results filter accordingly. I have been attempting to do this following examples and didn't get very far. However, here is what I have:
three list boxes, lstbreeder, lstcrop, lst fsspecialist. When I select a breeder (lstbreeder) it filters the next list box appropriately. I would like to be able to just choose a crop but no selections appear in the crop list box until a breeder is chosen.
The second problem is that I have a routine that will build a sql statement out of the results, however I don't know how to use it in the subform...at all. My weak attempt at coding something was the following:
Private Sub Child1_Enter()
Dim strsql As String
Dim qdf As String
strsql = "WHERE 1=1 "
strsql = strsql & BuildIn(Me!lstbreeder, "[Breeder]", "'")
strsql = strsql & BuildIn(Me!lstcrop, "[Crop]", "'")
strsql = strsql & BuildIn(Me!lstfsspecialist, "[FS Specialist]", "'")
If strsql <> "WHERE 1=1 " Then
Me.Filter = strsql
Me.FilterOn = True
Else
Me.FilterOn = False
End If
Me.Refresh
End Sub
Any help would be greatly appreciated!
I would like the results of a subform named Child1 to list the filtered results of the 3 list boxes. When none are selected, all records show and when selections are made the results filter accordingly. I have been attempting to do this following examples and didn't get very far. However, here is what I have:
three list boxes, lstbreeder, lstcrop, lst fsspecialist. When I select a breeder (lstbreeder) it filters the next list box appropriately. I would like to be able to just choose a crop but no selections appear in the crop list box until a breeder is chosen.
The second problem is that I have a routine that will build a sql statement out of the results, however I don't know how to use it in the subform...at all. My weak attempt at coding something was the following:
Private Sub Child1_Enter()
Dim strsql As String
Dim qdf As String
strsql = "WHERE 1=1 "
strsql = strsql & BuildIn(Me!lstbreeder, "[Breeder]", "'")
strsql = strsql & BuildIn(Me!lstcrop, "[Crop]", "'")
strsql = strsql & BuildIn(Me!lstfsspecialist, "[FS Specialist]", "'")
If strsql <> "WHERE 1=1 " Then
Me.Filter = strsql
Me.FilterOn = True
Else
Me.FilterOn = False
End If
Me.Refresh
End Sub
Any help would be greatly appreciated!