Connecting Tech Pros Worldwide Forums | Help | Site Map

Criteria For Subform Combobox Rowsource

Tom
Guest
 
Posts: n/a
#1: Nov 13 '05
I have the following tables:
TblState
StateID
State

TblCounty
CountyID
StateID
County

TblProjectState
ProjectStateID
ProjectID
StateID

TblProjectCounty
ProjectCountyID
ProjectStateID
CountyID

A project may be in multiple states and multiple counties in a state. I have
a main form based on TblProjectState and a subform based on
TblProjectCounty. There is a combobox in the main form with a row source of
TblState for entering StateID. How can I set up the rowsource for the
combobox in the subform for selecting counties? That combobox should only
list the counties in the State selected in the main form. I tried using a
query based on TblCounty and setting the criteria to
Forms!MyMainForm!StateID but the subform loads before the main form and
consequently StateID in the main form is not available to the criteria in
the query and a parameter dialog box comes up asking for
Forms!MyMainForm!StateID.

Thanks for all help!

Tom



RuralGuy
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Criteria For Subform Combobox Rowsource


Leave the RowSource of the ComboBox on the SubForm set to "" until the
AfterUpdate event of the ComboBox on the main form. Then:

Me!SubFormControlName.Form!ComboBoxName.RowSource = YourQuery (or
"Your SQL")

Replacing my dummy names with your real names of the SubFormControl
and the ConboBox.

On Mon, 22 Aug 2005 17:48:16 GMT, "Tom" <notmy@email.com> wrote:
[color=blue]
>I have the following tables:
>TblState
>StateID
>State
>
>TblCounty
>CountyID
>StateID
>County
>
>TblProjectState
>ProjectStateID
>ProjectID
>StateID
>
>TblProjectCounty
>ProjectCountyID
>ProjectStateID
>CountyID
>
>A project may be in multiple states and multiple counties in a state. I have
>a main form based on TblProjectState and a subform based on
>TblProjectCounty. There is a combobox in the main form with a row source of
>TblState for entering StateID. How can I set up the rowsource for the
>combobox in the subform for selecting counties? That combobox should only
>list the counties in the State selected in the main form. I tried using a
>query based on TblCounty and setting the criteria to
>Forms!MyMainForm!StateID but the subform loads before the main form and
>consequently StateID in the main form is not available to the criteria in
>the query and a parameter dialog box comes up asking for
>Forms!MyMainForm!StateID.
>
>Thanks for all help!
>
>Tom
>[/color]

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
Tom
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Criteria For Subform Combobox Rowsource


How will the combobox display any records previously entered when the form
opens if the combobox has no Row Source when the form opens?


<RuralGuy> wrote in message
news:p2jkg15tfpnbga8pkjpr8fid591gqr2u3f@4ax.com...[color=blue]
> Leave the RowSource of the ComboBox on the SubForm set to "" until the
> AfterUpdate event of the ComboBox on the main form. Then:
>
> Me!SubFormControlName.Form!ComboBoxName.RowSource = YourQuery (or
> "Your SQL")
>
> Replacing my dummy names with your real names of the SubFormControl
> and the ConboBox.
>
> On Mon, 22 Aug 2005 17:48:16 GMT, "Tom" <notmy@email.com> wrote:
>[color=green]
>>I have the following tables:
>>TblState
>>StateID
>>State
>>
>>TblCounty
>>CountyID
>>StateID
>>County
>>
>>TblProjectState
>>ProjectStateID
>>ProjectID
>>StateID
>>
>>TblProjectCounty
>>ProjectCountyID
>>ProjectStateID
>>CountyID
>>
>>A project may be in multiple states and multiple counties in a state. I
>>have
>>a main form based on TblProjectState and a subform based on
>>TblProjectCounty. There is a combobox in the main form with a row source
>>of
>>TblState for entering StateID. How can I set up the rowsource for the
>>combobox in the subform for selecting counties? That combobox should only
>>list the counties in the State selected in the main form. I tried using a
>>query based on TblCounty and setting the criteria to
>>Forms!MyMainForm!StateID but the subform loads before the main form and
>>consequently StateID in the main form is not available to the criteria in
>>the query and a parameter dialog box comes up asking for
>>Forms!MyMainForm!StateID.
>>
>>Thanks for all help!
>>
>>Tom
>>[/color]
>
> _______________________________________________
> hth - RuralGuy (RG for short)
> Please post to the NewsGroup so all may benefit.[/color]


Closed Thread


Similar Microsoft Access / VBA bytes