Cascading combo @ fontstuff.com

G

Guest

Hi.
I am using the cascading combo box example found at
http://www.fontstuff.com/access/acctut10.htm

Specifically I am using "Example #2: A Single Row Source Table" as all of my
information is also in one table.

It is very good and I got it to work, but can someone help me with the code
to add a 3rd combo box based on the previous two?

For example, in Mr. Green's example #2, what if you wanted to add a 3rd
column to the table and then filter a combo boxes based on the Country, City,
and whatever is in the 3rd column?

I just have one more criteria I want to choose from.

Thanks.
 
M

manningfan

Kelly -
I haven't seen the example but I did this for my previous employer.
When I did it, I created a query that filtered based on the value of
Combo1 and Combo2. Try messing with that idea, it should lead you in
the right direction.
 
G

Guest

Thanks manningfan!

Was your Combo 2 based on what you chose in Combo 1?

I have a similar search feature one a form elsewhere in the DB but the combo
boxes are not dependent on one another.

I'll look at it and see if it can be modified. The fontstuff.com one just
seemed so "clean".

Thanks again. Much appreciated.
 
M

manningfan

Yeah, Combo2 was based on Combo1, and then Combo3 was based on Combo2
and Combo1 together. If I had the code I'd throw it to you, but it
shouldn't be difficult to duplicate.

Not the cleanest way to do it, but it works. I think I just requeried
the following combo box on the "After Update" event of each combo box.
 
D

Douglas J Steele

Change the cboCountry_AfterUpdate code to:

Private Sub cboCountry_AfterUpdate()
On Error Resume Next
cboCity.RowSource = "Select Distinct tblAll.City " & _
"FROM tblAll " & _
"WHERE tblAll.Country = '" & cboCountry.Value & "' " & _
"ORDER BY tblAll.City"
End Sub

Add code for the cboCity_AfterUpdate event:

Private Sub cboCity_AfterUpdate()
On Error Resume Next
cboCombo3.RowSource = "Select Distinct tblAll.Column3 " & _
"FROM tblAll " & _
"WHERE tblAll.Country = '" & cboCountry.Value & "' " & _
"AND tblAll.City = '" & cboCity.Value & "' " & _
"ORDER BY tblAllColumn3"
End Sub
 
S

SharynInCambodia

Hi, not sure if anyone still gets these posts 2-3 years after the original
question was posed but just trying! i am just wondering if this method as
described in the tutorial is an alternative to placing criteria in the
rowsource of a forms field and then using VB code to requery in the after
update of the "parent" field? I am having trouble - i used the requery
method but have run into problems of not displaying the correct field entries
when looking back at old records - after new query has been done. This
method therefore looks like it would solve that problem although i can't get
it to work at all!
 

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