S
SueM
Hi,
I have a similar problem to Lucy - 1/9/03 8.39am, and have
tried Bruce's suggested solution to her on my problem.
I just want some advice on how to alter this solution to
fit my problem.
Instead of having a combobox and a subform I have 2
comboboxes one depending on the other for it's values.
This part I have entered in the row source of combo2 and
it works fine:
SELECT DISTINCT [Prod_No], [Prod_Desc] FROM ProdQ;
Now I need to narrow this down to only the results for the
product chosen in combo1 and have tried adjusting Bruce's
other suggested solution as follows:
Private Sub Combo1_AfterUpdate()
Dim strFilter As String
'Retrieve the combo's value
If Len(Trim(Me.Combo1.Value) & "") = 0 Then
strFilter = ""
Else
strFilter = "[Prod_No]=""" & Me.Combo1.Value & """"
End If
'Filter the subform
With Me.Combo2.Value
.Filter = strFilter
.FilterOn = True
End With
End Sub
But this last part isn't working for me. Any ideas on why
would be greatly appreciated. I'm thinking combos in wrong
places or maybe the Distinct thing shouldn't be used on 2
fields (though this works on its own) or maybe the last
With should be something other than .value.
Also do I need to work a requery into this or will this
automatically change when combo1 changes?
To date I've tried numerous queries with criteria to solve
this problem and have had no luck, so I'm really hoping to
get this one working
Cheers,
Sue
I have a similar problem to Lucy - 1/9/03 8.39am, and have
tried Bruce's suggested solution to her on my problem.
I just want some advice on how to alter this solution to
fit my problem.
Instead of having a combobox and a subform I have 2
comboboxes one depending on the other for it's values.
This part I have entered in the row source of combo2 and
it works fine:
SELECT DISTINCT [Prod_No], [Prod_Desc] FROM ProdQ;
Now I need to narrow this down to only the results for the
product chosen in combo1 and have tried adjusting Bruce's
other suggested solution as follows:
Private Sub Combo1_AfterUpdate()
Dim strFilter As String
'Retrieve the combo's value
If Len(Trim(Me.Combo1.Value) & "") = 0 Then
strFilter = ""
Else
strFilter = "[Prod_No]=""" & Me.Combo1.Value & """"
End If
'Filter the subform
With Me.Combo2.Value
.Filter = strFilter
.FilterOn = True
End With
End Sub
But this last part isn't working for me. Any ideas on why
would be greatly appreciated. I'm thinking combos in wrong
places or maybe the Distinct thing shouldn't be used on 2
fields (though this works on its own) or maybe the last
With should be something other than .value.
Also do I need to work a requery into this or will this
automatically change when combo1 changes?
To date I've tried numerous queries with criteria to solve
this problem and have had no luck, so I'm really hoping to
get this one working
Cheers,
Sue