can't get this cbx suggestion to work

J

jonah

I retrieved this guidance from a website but can not get
it to work.
"To filter records in a combo/listbox based on the value
selected in another combo/listbox, you can use a stored
query which uses the first control's value as a
parameter. For example,
Select PeopleID, PeopleName from tblPeople Where PeopleID
= Forms!FormName!NameOfFirstControl;
Then all you need to do is issue a Requery on the second
combo/listbox in this first control's AfterUpdate event.
Private Sub NameOfFirstControl_AfterUpdate()
Me!NameOfSecondControl.Requery
End Sub
I have a form that has two combo boxes. The first combo
box refers to the "Type" table as a rowsource. Based on
the type selected, ie 'sandwiches', I want the second
combo box to list PB&J, ham & cheese, etc. If 'soup' is
selected in the first cbx (cbxtype), I want vegetable,
potato, etc to be listed in the second cbx. The options
for the second cbx (cbxsubtype) are contained in
a "subtype" table that lists all of the subtypes and
their associated types
Subtype Table (tblsubtype):
type subtype
sandwiches ham & cheese
sandwiches PB&J
soup potato
soup vegetable
The way I have modified the above guidance is like this:

Select subtype from tblsubtype where type = forms!
typeentryform!cbxtype

The above I have entered into the rowsource for the
cbxsubtype, while writing code for the after update event
for the first cbx, cbxtype as:

Private Sub cbxtype_AfterUpdate()
Me!cbxtype.Requery
End sub

I have tried every variation I can think of (although I
am still trying to get a grasp on this)

Any help would be much appreciated.
Jonah
 
T

tina

your code is requerying the first combobox, not the second one. try changing
it to

Private Sub cbxtype_AfterUpdate()
Me!cbxsubtype.Requery
End Sub

hth
 
J

Jonah

Thank you very much.
That was it!
-----Original Message-----
your code is requerying the first combobox, not the second one. try changing
it to

Private Sub cbxtype_AfterUpdate()
Me!cbxsubtype.Requery
End Sub

hth





.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top