A
Andy Bailey
I have a subform that works okay by itself but gives me some problems when in
the main form.
The subform has a combo box to filter the contents of another combo box. The
code attached to the update/current/open events is:
Private Sub Category_AfterUpdate()
Me.Category.Requery
Me.CodeLookup.Requery
End Sub
Private Sub Form_Current()
Me.Category.Requery
Me.CodeLookup.Requery
End Sub
Private Sub Form_Open(Cancel As Integer)
Me.Category = Me.Category.ItemData(0)
Call Category_AfterUpdate
End Sub
and I have some criteria in the query behind the second combo:-
SELECT tblProducts.ProductID, tblProducts.Code, tblProducts.Name,
tblProducts.MiscText, tblProducts.Category
FROM tblProducts
WHERE (((tblProducts.Category)=[Forms]![frmProposalsSubform]![Category])) OR
((([Forms]![frmProposalsSubform]![Category])=1))
ORDER BY tblProducts.Code, tblProducts.Name;
This is fine when the subform is opened by itself but gives me four requests
for a parameter value Forms!frmProposalsSubform!Category when I open the main
form.
I know I've got my grammar wrong in the code and the query (which I
extracted from other posts as I'm a complete novice) - can anybody help
please? I've tried a number of ideas from other posts but I can't quite grasp
where I'm going wrong.
The idea of the first combo is to firstly allow all items in the second
combo to be displayed or filter them by a category.
Thanks - Andy
the main form.
The subform has a combo box to filter the contents of another combo box. The
code attached to the update/current/open events is:
Private Sub Category_AfterUpdate()
Me.Category.Requery
Me.CodeLookup.Requery
End Sub
Private Sub Form_Current()
Me.Category.Requery
Me.CodeLookup.Requery
End Sub
Private Sub Form_Open(Cancel As Integer)
Me.Category = Me.Category.ItemData(0)
Call Category_AfterUpdate
End Sub
and I have some criteria in the query behind the second combo:-
SELECT tblProducts.ProductID, tblProducts.Code, tblProducts.Name,
tblProducts.MiscText, tblProducts.Category
FROM tblProducts
WHERE (((tblProducts.Category)=[Forms]![frmProposalsSubform]![Category])) OR
((([Forms]![frmProposalsSubform]![Category])=1))
ORDER BY tblProducts.Code, tblProducts.Name;
This is fine when the subform is opened by itself but gives me four requests
for a parameter value Forms!frmProposalsSubform!Category when I open the main
form.
I know I've got my grammar wrong in the code and the query (which I
extracted from other posts as I'm a complete novice) - can anybody help
please? I've tried a number of ideas from other posts but I can't quite grasp
where I'm going wrong.
The idea of the first combo is to firstly allow all items in the second
combo to be displayed or filter them by a category.
Thanks - Andy