Combo Boxes

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

    #1

    Combo Boxes

    I am trying to populate my combo box with a table from another database
    and I am not sure how to start the coding for that... Does anyone have
    a sample I code look at?

  • Tanis

    #2
    Re: Combo Boxes


    gemilie wrote:[color=blue]
    > I am trying to populate my combo box with a table from another[/color]
    database[color=blue]
    > and I am not sure how to start the coding for that... Does anyone[/color]
    have[color=blue]
    > a sample I code look at?[/color]
    Import the table as a linked table, then populate your combo from that.

    Comment

    • Olaf Rabbachin

      #3
      Re: Combo Boxes

      Hi,

      gemilie wrote:
      [color=blue]
      > I am trying to populate my combo box with a table from another database
      > and I am not sure how to start the coding for that... Does anyone have
      > a sample I code look at?[/color]

      if you're talking about changing databases here, you might want to setup
      your combo's query at runtime (after you know the path/filename) with
      something like this:

      SELECT *
      FROM [C:\MyPath\MyDat aDB.mdb].tbl_MyTableInT here;

      This might also be used to directly fill the combo from a form's event
      instead of creating a query and using that with the combo using the
      property-sheet.

      Cheers,
      Olaf [MVP]
      --
      My .02: www.Resources.IntuiDev.com

      Comment

      • gemilie

        #4
        Re: Combo Boxes

        I need to populate the combo box without linking the table. I know I
        need to use a ADO "getString" But I just don't know how to start off
        the code to grab the data I need. I do not want the comdo linked to the
        table all the time.
        Olaf Rabbachin wrote:[color=blue]
        > Hi,
        >
        > gemilie wrote:
        >[color=green]
        > > I am trying to populate my combo box with a table from another[/color][/color]
        database[color=blue][color=green]
        > > and I am not sure how to start the coding for that... Does anyone[/color][/color]
        have[color=blue][color=green]
        > > a sample I code look at?[/color]
        >
        > if you're talking about changing databases here, you might want to[/color]
        setup[color=blue]
        > your combo's query at runtime (after you know the path/filename) with
        > something like this:
        >
        > SELECT *
        > FROM [C:\MyPath\MyDat aDB.mdb].tbl_MyTableInT here;
        >
        > This might also be used to directly fill the combo from a form's[/color]
        event[color=blue]
        > instead of creating a query and using that with the combo using the
        > property-sheet.
        >
        > Cheers,
        > Olaf [MVP]
        > --
        > My .02: www.Resources.IntuiDev.com[/color]

        Comment

        • Olaf Rabbachin

          #5
          Re: Combo Boxes

          Hi,

          gemilie wrote:
          [color=blue]
          > I need to populate the combo box without linking the table. I know I
          > need to use a ADO "getString" But I just don't know how to start off
          > the code to grab the data I need. I do not want the comdo linked to the
          > table all the time.[/color]

          no ADO involved there. Just adjust the query-string I posted to your
          requirements and use it i.e. within the form's Current-event (or whenever
          appropriate) to set your combo's RowSource-property, that's all.

          Cheers,
          Olaf [MVP]
          --
          My .02: www.Resources.IntuiDev.com

          Comment

          • gemilie

            #6
            Re: Combo Boxes

            Do you mean that the code above should be used in the rowsource
            property. I know I should get this but I don't. I am not sure how to
            set it up in the current event....
            Olaf Rabbachin wrote:[color=blue]
            > Hi,
            >
            > gemilie wrote:
            >[color=green]
            > > I need to populate the combo box without linking the table. I know[/color][/color]
            I[color=blue][color=green]
            > > need to use a ADO "getString" But I just don't know how to start[/color][/color]
            off[color=blue][color=green]
            > > the code to grab the data I need. I do not want the comdo linked to[/color][/color]
            the[color=blue][color=green]
            > > table all the time.[/color]
            >
            > no ADO involved there. Just adjust the query-string I posted to your
            > requirements and use it i.e. within the form's Current-event (or[/color]
            whenever[color=blue]
            > appropriate) to set your combo's RowSource-property, that's all.
            >
            > Cheers,
            > Olaf [MVP]
            > --
            > My .02: www.Resources.IntuiDev.com[/color]

            Comment

            • Olaf Rabbachin

              #7
              Re: Combo Boxes

              Hi,

              gemilie wrote:
              [color=blue]
              > Do you mean that the code above should be used in the rowsource
              > property.[/color]

              yes.
              [color=blue]
              > I know I should get this but I don't. I am not sure how to
              > set it up in the current event....[/color]

              Exactly when do you know the path and filename of that database where the
              information that is to be shown within your combo is stored?

              Cheers,
              Olaf [MVP]
              --
              My .02: www.Resources.IntuiDev.com

              Comment

              • gemilie

                #8
                Re: Combo Boxes

                Olaf,

                I tried using

                SELECT *
                FROM [C:\MyPath\MyDat aDB.mdb].tbl_MyTableInT here;

                in the rowsource with my path and tble name but it is not working...
                Any other ideas?

                Thanks for all your help!

                Olaf Rabbachin wrote:[color=blue]
                > Hi,
                >
                > gemilie wrote:
                >[color=green]
                > > Do you mean that the code above should be used in the rowsource
                > > property.[/color]
                >
                > yes.
                >[color=green]
                > > I know I should get this but I don't. I am not sure how to
                > > set it up in the current event....[/color]
                >
                > Exactly when do you know the path and filename of that database where[/color]
                the[color=blue]
                > information that is to be shown within your combo is stored?
                >
                > Cheers,
                > Olaf [MVP]
                > --
                > My .02: www.Resources.IntuiDev.com[/color]

                Comment

                • Olaf Rabbachin

                  #9
                  Re: Combo Boxes

                  Hi,

                  gemilie wrote:
                  [color=blue]
                  > I tried using
                  >
                  > SELECT *
                  > FROM [C:\MyPath\MyDat aDB.mdb].tbl_MyTableInT here;
                  >
                  > in the rowsource with my path and tble name but it is not working...[/color]

                  First of all, try to create a regular query to see whether the data is
                  being returned at all. Replacing path, filename and table-name in the above
                  statement with valid names MUST return data, unless you are talking about a
                  secured database (either workgroup-based or password-protected).

                  After that you'll have to find out exactly when you get to know the path to
                  that database you'd like to query and setup the RowSource-string
                  accordingly or, if a saved query is to be used, change the query's
                  SQL-property.
                  If you would like the form to pull the database-path information from
                  somewhere when it's being opened (i.e. the combobox will show the same
                  records during its lifetime resp. it doesn't have to change when looping
                  through records), you might want to use the Form_Load-event to setup the
                  combo's RowSource-property instead of the Form_Current-event (where the
                  combobox will query the external database each time you move to a different
                  record).

                  Cheers,
                  Olaf [MVP]
                  --
                  My .02: www.Resources.IntuiDev.com

                  Comment

                  • Olaf Rabbachin

                    #10
                    Re: Combo Boxes

                    Hi,

                    FWIW - I've created a small sample-database. Check out the "Querying
                    external DBs on the fly"-sample on my website (see signature).

                    Cheers,
                    Olaf [MVP]
                    --
                    My .02: www.Resources.IntuiDev.com

                    Comment

                    Working...