Criteria For Subform Combobox Rowsource

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tom

    Criteria For Subform Combobox Rowsource

    I have the following tables:
    TblState
    StateID
    State

    TblCounty
    CountyID
    StateID
    County

    TblProjectState
    ProjectStateID
    ProjectID
    StateID

    TblProjectCount y
    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
    TblProjectCount y. 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!MyMainFor m!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!MyMainFor m!StateID.

    Thanks for all help!

    Tom


  • RuralGuy

    #2
    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!SubFormContr olName.Form!Com boBoxName.RowSo urce = 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.co m> wrote:
    [color=blue]
    >I have the following tables:
    >TblState
    >StateID
    >State
    >
    >TblCounty
    >CountyID
    >StateID
    >County
    >
    >TblProjectStat e
    >ProjectState ID
    >ProjectID
    >StateID
    >
    >TblProjectCoun ty
    >ProjectCountyI D
    >ProjectState ID
    >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
    >TblProjectCoun ty. 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!MyMainFo rm!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!MyMainFo rm!StateID.
    >
    >Thanks for all help!
    >
    >Tom
    >[/color]

    _______________ _______________ _______________ __
    hth - RuralGuy (RG for short)
    Please post to the NewsGroup so all may benefit.

    Comment

    • Tom

      #3
      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:p2jkg15tfp nbga8pkjpr8fid5 91gqr2u3f@4ax.c om...[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!SubFormContr olName.Form!Com boBoxName.RowSo urce = 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.co m> wrote:
      >[color=green]
      >>I have the following tables:
      >>TblState
      >>StateID
      >>State
      >>
      >>TblCounty
      >>CountyID
      >>StateID
      >>County
      >>
      >>TblProjectSta te
      >>ProjectStateI D
      >>ProjectID
      >>StateID
      >>
      >>TblProjectCou nty
      >>ProjectCounty ID
      >>ProjectStateI D
      >>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
      >>TblProjectCou nty. 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!MyMainF orm!StateID but the subform loads before the main form and
      >>consequentl y StateID in the main form is not available to the criteria in
      >>the query and a parameter dialog box comes up asking for
      >>Forms!MyMainF orm!StateID.
      >>
      >>Thanks for all help!
      >>
      >>Tom
      >>[/color]
      >
      > _______________ _______________ _______________ __
      > hth - RuralGuy (RG for short)
      > Please post to the NewsGroup so all may benefit.[/color]


      Comment

      Working...