Rosy wrote:
Quote:
I need to have a form filter from two differnt fields.
>
First the user needs to be able to pick from a list of categories.
Then the user needs to be able to choose a size from the results of
the category.
>
If i set the parameters in the query, then they can't choose from the
list.
>
This is what I came up with, but when you use the second drop down
box, it doesn't pull from just teh results of the first box.
>
Private Sub Combo1_Change()
Dim strFilter
strFilter = "[VesselCategory]=""" & Combo1.Text & """"
Form_AllJobs.Visible = True
Form_AllJobs.Filter = strFilter
Form_AllJobs.FilterOn = True
Form_AllJobs.Refresh
End Sub
>
>
>
Private Sub Combo32_Change()
Dim strFilter
strFilter = "[Vesselsizerange]=""" & Combo32.Text & """"
Form_AllJobs.Visible = True
Form_AllJobs.Filter = strFilter
Form_AllJobs.FilterOn = True
Form_AllJobs.Refresh
End Sub
|
I sometimes do something like this. First, I use the AfterUpdate event
but it probably doesn't make any difference...I just like to have it
make it past the NotInList event or any error routines that may exist
before setting the filter.
Private Sub Combo1_AfterUpdate()
'refresh the list in combo 32 to associate with Combo1
Me.Combo32.Requery
SetFilter
ENd Sub
Private Sub Combo32_AfterUpdate()
SetFilter
ENd Sub
Private Sub SetFilter()
Dim strFilter
IF Not IsNull(Me.Combo1) then
strFilter = "[VesselCategory]='" & Me.Combo1 & "' And "
IF Not IsNull(Me.Combo32) then
strFilter = strFilter & _
"[Vesselsizerange]='" & Combo32 & "' And "
Endif
Endif
If strFilter "" THen
'remove the "And"
strFilter = _
Left(strFilter,len(strFilter)-5)
Endif
Form_AllJobs.Filter = strFilter
Form_AllJobs.FilterOn = (strFilter "")
End Sub
BristleBot Cat Toy
http://www.youtube.com/watch?v=rUSTXUis_ys