Combo Box

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

    Combo Box

    Dear All,

    I have two tables i.e States and Cities and it has a one to many
    relationship as one state has many cities. Now, when i make a form and
    create two combo boxes for states and cities what i want the state
    combo box to do is: when a speicific state is selected in state combo
    box the second combo (City) should only show the cities that bleong to
    the selected State.

    I hope you will help me in this,

    I thank you people in advance,

    farhaaad

  • fredg

    #2
    Re: Combo Box

    On 19 May 2007 21:52:31 -0700, Farhaad Faaique wrote:
    Dear All,
    >
    I have two tables i.e States and Cities and it has a one to many
    relationship as one state has many cities. Now, when i make a form and
    create two combo boxes for states and cities what i want the state
    combo box to do is: when a speicific state is selected in state combo
    box the second combo (City) should only show the cities that bleong to
    the selected State.
    >
    I hope you will help me in this,
    >
    I thank you people in advance,
    >
    farhaaad
    Set the City combo box RowsourceType property to Table/Query.
    Leave the City combo box Rowsource property blank.


    Code the State Combo box AfterUpdate event:
    CityCombo.RowSo urce = "Select TableName.[City] From TableName Where
    TableName.[State] = '" & Me.StateCombo & "' Order by [City];"

    --
    Fred
    Please respond only to this newsgroup.
    I do not reply to personal e-mail

    Comment

    • Farhaad Faaique

      #3
      Re: Combo Box

      On May 20, 10:32 am, fredg <fgutk...@examp le.invalidwrote :
      On 19 May 2007 21:52:31 -0700, Farhaad Faaique wrote:
      >
      Dear All,
      >
      I have two tables i.e States and Cities and it has a one to many
      relationship as one state has many cities. Now, when i make a form and
      create two combo boxes for states and cities what i want the state
      combo box to do is: when a speicific state is selected in state combo
      box the second combo (City) should only show the cities that bleong to
      the selected State.
      >
      I hope you will help me in this,
      >
      I thank you people in advance,
      >
      farhaaad
      >
      Set the City combo box RowsourceType property to Table/Query.
      Leave the City combo box Rowsource property blank.
      >
      Code the State Combo box AfterUpdate event:
      CityCombo.RowSo urce = "Select TableName.[City] From TableName Where
      TableName.[State] = '" & Me.StateCombo & "' Order by [City];"
      >
      --
      Fred
      Please respond only to this newsgroup.
      I do not reply to personal e-mail
      I thank you very much for this, but still i have a problem if you can
      solve it. with the same codeline it says DATA TYPE MISMATCH IN
      CRITERIA EXPRESSION
      here is my codeline:

      City.RowSource = "select Cities.[City] from Cities where Cities.
      [State_ID] = '" & Me.Combo0.Colum n(0) & "' orderby [City];"

      can you tell me what is wrong with it please?
      Thanks alot.

      Farhaad

      Comment

      • salad

        #4
        Re: Combo Box

        Farhaad Faaique wrote:
        On May 20, 10:32 am, fredg <fgutk...@examp le.invalidwrote :
        >
        >>On 19 May 2007 21:52:31 -0700, Farhaad Faaique wrote:
        >>
        >>
        >>>Dear All,
        >>
        >>>I have two tables i.e States and Cities and it has a one to many
        >>>relationsh ip as one state has many cities. Now, when i make a form and
        >>>create two combo boxes for states and cities what i want the state
        >>>combo box to do is: when a speicific state is selected in state combo
        >>>box the second combo (City) should only show the cities that bleong to
        >>>the selected State.
        >>
        >>>I hope you will help me in this,
        >>
        >>>I thank you people in advance,
        >>
        >>>farhaaad
        >>
        >>Set the City combo box RowsourceType property to Table/Query.
        >>Leave the City combo box Rowsource property blank.
        >>
        >>Code the State Combo box AfterUpdate event:
        >>CityCombo.Row Source = "Select TableName.[City] From TableName Where
        >>TableName.[State] = '" & Me.StateCombo & "' Order by [City];"
        >>
        >>--
        >>Fred
        >>Please respond only to this newsgroup.
        >>I do not reply to personal e-mail
        >
        >
        I thank you very much for this, but still i have a problem if you can
        solve it. with the same codeline it says DATA TYPE MISMATCH IN
        CRITERIA EXPRESSION
        here is my codeline:
        >
        City.RowSource = "select Cities.[City] from Cities where Cities.
        [State_ID] = '" & Me.Combo0.Colum n(0) & "' orderby [City];"
        >
        can you tell me what is wrong with it please?
        Thanks alot.
        >
        Farhaad
        >
        Should orderby should be order by?

        Comment

        • fredg

          #5
          Re: Combo Box

          On 20 May 2007 04:16:55 -0700, Farhaad Faaique wrote:
          On May 20, 10:32 am, fredg <fgutk...@examp le.invalidwrote :
          >On 19 May 2007 21:52:31 -0700, Farhaad Faaique wrote:
          >>
          >>Dear All,
          >>
          >>I have two tables i.e States and Cities and it has a one to many
          >>relationshi p as one state has many cities. Now, when i make a form and
          >>create two combo boxes for states and cities what i want the state
          >>combo box to do is: when a speicific state is selected in state combo
          >>box the second combo (City) should only show the cities that bleong to
          >>the selected State.
          >>
          >>I hope you will help me in this,
          >>
          >>I thank you people in advance,
          >>
          >>farhaaad
          >>
          >Set the City combo box RowsourceType property to Table/Query.
          >Leave the City combo box Rowsource property blank.
          >>
          >Code the State Combo box AfterUpdate event:
          >CityCombo.RowS ource = "Select TableName.[City] From TableName Where
          >TableName.[State] = '" & Me.StateCombo & "' Order by [City];"
          >>
          >--
          >Fred
          >Please respond only to this newsgroup.
          >I do not reply to personal e-mail
          >
          I thank you very much for this, but still i have a problem if you can
          solve it. with the same codeline it says DATA TYPE MISMATCH IN
          CRITERIA EXPRESSION
          here is my codeline:
          >
          City.RowSource = "select Cities.[City] from Cities where Cities.
          [State_ID] = '" & Me.Combo0.Colum n(0) & "' orderby [City];"
          >
          can you tell me what is wrong with it please?
          Thanks alot.
          >
          Farhaad
          Evidently your field name is State_ID, a Number datatype, not State, a
          Text datatype. And yes, it should be Order By.
          Try:

          City.RowSource = "select Cities.[City] from Cities where Cities.
          [State_ID] = " & Me.Combo0.Colum n(0) & " order by [City];"

          Note: when asking questions in the future, it's always best to give
          your actual Table Field names and their datatypes. The syntax is
          different for Number, Text, and Date datatypes.
          --
          Fred
          Please respond only to this newsgroup.
          I do not reply to personal e-mail

          Comment

          • Farhaad Faaique

            #6
            Re: Combo Box

            On May 21, 2:10 am, fredg <fgutk...@examp le.invalidwrote :
            On 20 May 2007 04:16:55 -0700, Farhaad Faaique wrote:
            >
            >
            >
            >
            >
            On May 20, 10:32 am, fredg <fgutk...@examp le.invalidwrote :
            On 19 May 2007 21:52:31 -0700, Farhaad Faaique wrote:
            >
            >Dear All,
            >
            >I have two tables i.e States and Cities and it has a one to many
            >relationship as one state has many cities. Now, when i make a form and
            >create two combo boxes for states and cities what i want the state
            >combo box to do is: when a speicific state is selected in state combo
            >box the second combo (City) should only show the cities that bleong to
            >the selected State.
            >
            >I hope you will help me in this,
            >
            >I thank you people in advance,
            >
            >farhaaad
            >
            Set the City combo box RowsourceType property to Table/Query.
            Leave the City combo box Rowsource property blank.
            >
            Code the State Combo box AfterUpdate event:
            CityCombo.RowSo urce = "Select TableName.[City] From TableName Where
            TableName.[State] = '" & Me.StateCombo & "' Order by [City];"
            >
            --
            Fred
            Please respond only to this newsgroup.
            I do not reply to personal e-mail
            >
            I thank you very much for this, but still i have a problem if you can
            solve it. with the same codeline it says DATA TYPE MISMATCH IN
            CRITERIA EXPRESSION
            here is my codeline:
            >
            City.RowSource = "select Cities.[City] from Cities where Cities.
            [State_ID] = '" & Me.Combo0.Colum n(0) & "' orderby [City];"
            >
            can you tell me what is wrong with it please?
            Thanks alot.
            >
            Farhaad
            >
            Evidently your field name is State_ID, a Number datatype, not State, a
            Text datatype. And yes, it should be Order By.
            Try:
            >
            City.RowSource = "select Cities.[City] from Cities where Cities.
            [State_ID] = " & Me.Combo0.Colum n(0) & " order by [City];"
            >
            Note: when asking questions in the future, it's always best to give
            your actual Table Field names and their datatypes. The syntax is
            different for Number, Text, and Date datatypes.
            --
            Fred
            Please respond only to this newsgroup.
            I do not reply to personal e-mail- Hide quoted text -
            >
            - Show quoted text -
            Thanks alot.
            It worked

            Comment

            Working...