Populating a ComboBox from a Dbase


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Populating a ComboBox from a Dbase

  1. #1
    Frank Guest

    Populating a ComboBox from a Dbase


    Hello,
    I am VERY new at this so this might seem like a simple problem to most,
    but what I'm trying to do is populate a combo box from a access database
    automaticaly when the form is loaded. It shouldn't be more than 3 - 4 lines
    of code but I can't find it anywhere and need it for a school project. Thank-you
    in advance. Frank

  2. #2
    Craig Brown Guest

    Re: Populating a ComboBox from a Dbase


    Frank,

    Without actually doing your homework for you (in which case you'd still be
    at the same point you are now...), here's one approach to get you started:

    1) You need to connect to your database.
    2) You need to query the database for the info to populate the combo box.
    3) You need to loop through the query's resultset, adding each value returned
    into the combo box using the AddItem method.

    An additional suggestion would be to set up your query so that it returns
    only the field you need. There are quite a few examples of how to do parts
    of this in the help facility, not all of them good, but at least you can
    see the syntax.

    By the way, using the database to populate your combo box is a great way
    to provide dynamic updates, and reduce the amount of editting your program
    must do... If a new row is added to the database, presto, your program loads
    it. Since you, the program, put all the data in there in the first place,
    you, the program, should understand it.

    If you have a specific problem, post the code, along with what you've tried
    and where you think the problem lies. We'll try to help you from there.

    Craig Brown


    "Frank" <fciliberto@aol.com> wrote:
    >
    >Hello,
    > I am VERY new at this so this might seem like a simple problem to most,
    >but what I'm trying to do is populate a combo box from a access database
    >automaticaly when the form is loaded. It shouldn't be more than 3 - 4 lines
    >of code but I can't find it anywhere and need it for a school project.

    Thank-you
    >in advance. Frank



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center