Co-ordinating comboboxes

G

Guest

This is a variation of a question that Marshall Barton provided a good
solution for a few days ago. I just can't seem to get this perfect.

I now have 3 unbound comboboxes (cbxReg and cbxArea and cbxDistrict) on my
form. cbxArea gets its RowSource from the AfterUpdate event of cbxReg, and
cbxDistrict gets its RowSource from the AfterUpdate event of cbxArea. For
example, here is cbxReg's AfterUpdate code.

Me!cbxArea.RowSource = "SELECT qryData.AreaID,qryData.AreaName
FROM qryData WHERE RegID= " & Me!cbxReg.Column(0) & ";"
Me!cbxReg.Value = [cbxReg].[ItemData](0)
Me.Requery
Me!cbxArea.SetFocus

Similar code in cbxArea provides the RowSource for cbxDistrict.

Here is my difficulty. When the form opens and I select a Region, the Area
combo shows its 1st 'where-matching' value properly. But I also want the
District combo to show its first 'where-matching' value as well. As it is
now, I first have to update cbxArea before cbxDistrict shows the appropriate
values. How do I get the 3rd combobox to properly update once I've selected
a value from the 1st?
 
R

Rick Brandt

Sophie said:
This is a variation of a question that Marshall Barton provided a good
solution for a few days ago. I just can't seem to get this perfect.

I now have 3 unbound comboboxes (cbxReg and cbxArea and cbxDistrict)
on my form. cbxArea gets its RowSource from the AfterUpdate event
of cbxReg, and cbxDistrict gets its RowSource from the AfterUpdate
event of cbxArea. For example, here is cbxReg's AfterUpdate code.

Me!cbxArea.RowSource = "SELECT qryData.AreaID,qryData.AreaName
FROM qryData WHERE RegID= " & Me!cbxReg.Column(0) & ";"
Me!cbxReg.Value = [cbxReg].[ItemData](0)
Me.Requery
Me!cbxArea.SetFocus

Similar code in cbxArea provides the RowSource for cbxDistrict.

Here is my difficulty. When the form opens and I select a Region,
the Area combo shows its 1st 'where-matching' value properly. But I
also want the District combo to show its first 'where-matching' value
as well. As it is now, I first have to update cbxArea before
cbxDistrict shows the appropriate values. How do I get the 3rd
combobox to properly update once I've selected a value from the 1st?

In the AfterUpdate event of cbxReg you need to call the AfterUpdate event of
cbxArea.
 
G

Guest

Wow - that was fast. Seems like I just hit <Post>.
--
Thanks
Sophie


Rick Brandt said:
Sophie said:
This is a variation of a question that Marshall Barton provided a good
solution for a few days ago. I just can't seem to get this perfect.

I now have 3 unbound comboboxes (cbxReg and cbxArea and cbxDistrict)
on my form. cbxArea gets its RowSource from the AfterUpdate event
of cbxReg, and cbxDistrict gets its RowSource from the AfterUpdate
event of cbxArea. For example, here is cbxReg's AfterUpdate code.

Me!cbxArea.RowSource = "SELECT qryData.AreaID,qryData.AreaName
FROM qryData WHERE RegID= " & Me!cbxReg.Column(0) & ";"
Me!cbxReg.Value = [cbxReg].[ItemData](0)
Me.Requery
Me!cbxArea.SetFocus

Similar code in cbxArea provides the RowSource for cbxDistrict.

Here is my difficulty. When the form opens and I select a Region,
the Area combo shows its 1st 'where-matching' value properly. But I
also want the District combo to show its first 'where-matching' value
as well. As it is now, I first have to update cbxArea before
cbxDistrict shows the appropriate values. How do I get the 3rd
combobox to properly update once I've selected a value from the 1st?

In the AfterUpdate event of cbxReg you need to call the AfterUpdate event of
cbxArea.
 

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

Similar Threads


Top