Sid <ad******@gmail.comwrote in
news:11**********************@k79g2000hse.googlegr oups.com:
I need some help in setting up Access combo box.
I am using three comboboxes in my form. Comb Box 1, Combo Box
2, Combo Box 3. The row source for each of the combo box is a
seperate table.
Table 1 acts as row source for Combo Box 1
Table 2 acts as row source for Combo Box 2
However for combobox 3, I was trying to use 4 different tables
as row source. I am trying to set up a criteria such that row
source for comb box depends on what is selected in combo box 1
& 2
sorry if I made the question overly complicated.
Just as an example......
Combo box 1 - State
Combo Box 2 - City
Combo Box 3 - Zip code
now i am trying to display only zip codes that fit in a
particular city and state combination.
I would greatly appreciate if someone could help me with this.
I have killed my weekend trying to figure out how this could
work.
Thanks,
Sid
What you give as an example is very different from your question
because all zip codes are (should be) in one table. Having one
table with a filter is very different from having four (4)
separate tables.
Anyways FWIW, code for your example would be as follows:
cboState's row source is of course
SELECT Distinct State from tblCipCodes;
In the afterUpdate event for State, you execute the statement
me.cboCity.requery.
cboCity's rowsource is
SELECT Distinct City from tblZipCodes
Where State = forms!cboState.value ;
in the afterUpdate event for cboCity put
me.cboZipCodes.requery.
cboZipCodes row source would be
SELECT ZipCode FROM tblZipCodes
WHERE State = forms!myForm!cboState
AND City = forms!myForm!cboCity
But you need to select a different .rowsource property based on
the selection of the first two combos. which is much more
involved. Usually it is also a sign of poor normalization.
More information please: what are the four tables and how do
they relate to the first two combo boxes?
--
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from
http://www.teranews.com