Combo boxes (query dependent on prior selection)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a form with 4 combo boxes on it (1, 2, 3, 4) and the row
sources for combo boxes are queries.

The selection made in Combo box #1 will act as a criteria for the query
being used as a row source for combo #2 (after the Click event on combo #2).
Likewise, selection in #2 limits the query row source in combo #3 etc.

While the queries are working fine (after the click event on the prior
combo), the problem I am having is, for example) after combo #1 is selected
and before the click event in Combo #2, I need combo #2 to display the first
record in the filtered query. As of now, it still displays the prior
selection made with combo #2 even though the available row source has changed
due to the fact that selection made with combo #1 has changed..

Can anybody tell me what I need to do to force a combo box to display the
first record in it's row source anytime that row source changes.

Pele
 
Something like the following in Combo1_AfterUpdate:

Me.Combo2.Value = Me.Combo2.ItemData(0)
Combo2_AfterUpdate '(which updates Combo3, etc.)

HTH,
 
George,

I put the following code directly in the AfterUpdate property of the first
combo box called "Select BU" to try and preselect the combo box "Select
Group". Unfortunately, Access said that "can't find macro called Me".

me.[select group].value=me.[select group].ItemData(0)

Should this be done as an event procedure. Can you help write the event
procedure to do something like this.

Pele
 
Yes, it should be an event procedure.

Let Access create the procedure skeleton for you, then insert that line.

--
George Nicholson

Remove 'Junk' from return address.


Pele said:
George,

I put the following code directly in the AfterUpdate property of the first
combo box called "Select BU" to try and preselect the combo box "Select
Group". Unfortunately, Access said that "can't find macro called Me".

me.[select group].value=me.[select group].ItemData(0)

Should this be done as an event procedure. Can you help write the event
procedure to do something like this.

Pele

George Nicholson said:
Something like the following in Combo1_AfterUpdate:

Me.Combo2.Value = Me.Combo2.ItemData(0)
Combo2_AfterUpdate '(which updates Combo3, etc.)

HTH,
 
George,

Thanks for the suggestion; it works fine. Could you tell me how I can get
the Before Update event procedure to also run a macro. I have already created
the macro and I would want the event procedure to run it (since I can't use
the macro) at the Before Update property of the combo anymore.

Pele

George Nicholson said:
Yes, it should be an event procedure.

Let Access create the procedure skeleton for you, then insert that line.

--
George Nicholson

Remove 'Junk' from return address.


Pele said:
George,

I put the following code directly in the AfterUpdate property of the first
combo box called "Select BU" to try and preselect the combo box "Select
Group". Unfortunately, Access said that "can't find macro called Me".

me.[select group].value=me.[select group].ItemData(0)

Should this be done as an event procedure. Can you help write the event
procedure to do something like this.

Pele

George Nicholson said:
Something like the following in Combo1_AfterUpdate:

Me.Combo2.Value = Me.Combo2.ItemData(0)
Combo2_AfterUpdate '(which updates Combo3, etc.)

HTH,
--
George Nicholson

Remove 'Junk' from return address.


I have created a form with 4 combo boxes on it (1, 2, 3, 4) and the row
sources for combo boxes are queries.

The selection made in Combo box #1 will act as a criteria for the query
being used as a row source for combo #2 (after the Click event on combo
#2).
Likewise, selection in #2 limits the query row source in combo #3 etc.

While the queries are working fine (after the click event on the prior
combo), the problem I am having is, for example) after combo #1 is
selected
and before the click event in Combo #2, I need combo #2 to display the
first
record in the filtered query. As of now, it still displays the prior
selection made with combo #2 even though the available row source has
changed
due to the fact that selection made with combo #1 has changed..

Can anybody tell me what I need to do to force a combo box to display
the
first record in it's row source anytime that row source changes.

Pele
 
DoCmd.RunMacro "Substitute Existing Macro Name"

I've never used this myself because I rarely use macros, but according to VB
help, that should do it.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


Pele said:
George,

Thanks for the suggestion; it works fine. Could you tell me how I can get
the Before Update event procedure to also run a macro. I have already
created
the macro and I would want the event procedure to run it (since I can't
use
the macro) at the Before Update property of the combo anymore.

Pele

George Nicholson said:
Yes, it should be an event procedure.

Let Access create the procedure skeleton for you, then insert that line.

--
George Nicholson

Remove 'Junk' from return address.


Pele said:
George,

I put the following code directly in the AfterUpdate property of the
first
combo box called "Select BU" to try and preselect the combo box "Select
Group". Unfortunately, Access said that "can't find macro called Me".

me.[select group].value=me.[select group].ItemData(0)

Should this be done as an event procedure. Can you help write the event
procedure to do something like this.

Pele

:

Something like the following in Combo1_AfterUpdate:

Me.Combo2.Value = Me.Combo2.ItemData(0)
Combo2_AfterUpdate '(which updates Combo3, etc.)

HTH,
--
George Nicholson

Remove 'Junk' from return address.


I have created a form with 4 combo boxes on it (1, 2, 3, 4) and the
row
sources for combo boxes are queries.

The selection made in Combo box #1 will act as a criteria for the
query
being used as a row source for combo #2 (after the Click event on
combo
#2).
Likewise, selection in #2 limits the query row source in combo #3
etc.

While the queries are working fine (after the click event on the
prior
combo), the problem I am having is, for example) after combo #1 is
selected
and before the click event in Combo #2, I need combo #2 to display
the
first
record in the filtered query. As of now, it still displays the prior
selection made with combo #2 even though the available row source
has
changed
due to the fact that selection made with combo #1 has changed..

Can anybody tell me what I need to do to force a combo box to
display
the
first record in it's row source anytime that row source changes.

Pele
 
Back
Top