Filling Combo box using ADO


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Filling Combo box using ADO

  1. #1
    Shravan Guest

    Filling Combo box using ADO


    I need to fill 10 Combo boxes using ADO. I have written the code and it only
    works on the load event of the form in visual basic. I tried to have the
    code in the Combo box click event but when i go through the events, i dont
    even find a trace of the procedure for combo click event being called. Any
    ides or suggestions in this regard would be appreciated.

    Shravan

  2. #2
    Sofie Guest

    Re: Filling Combo box using ADO


    Try this:

    Private Sub msb_FillCombo1()
    'Fill combo box with data
    'Declare and set connection and recordset objects
    Dim mrst As ADOB.Recordset
    Dim pconObj As ADOB.Connection
    Dim strSQL as String

    Set pconObj AS ..... "Finish the rest
    strSQL = "SELECT "Field name you want to fill the combo with" FROM "Your

    Database name" "Any criteria here"
    Set mrst AS ...... "Finish the rest

    mrst.MoveFirst
    Do Until mrst.EOF
    cbo1.AddItem mrst!fldName
    cbo1.ItemData(cbo1.NewIndex) = mrst!fldName_ID
    mrst.MoveNext
    Loop

    End Sub
    mrst.MoveFirst

    Then, place the "msb_FillCombo1" in the Form Load. If your 10 combo boxes
    are to contain different data then you might need to create 10 different
    Fill Combo Sub Procedures.

    good Luck





    "Shravan" <shravan79@hotmail.com> wrote:
    >
    >I need to fill 10 Combo boxes using ADO. I have written the code and it

    only
    >works on the load event of the form in visual basic. I tried to have the
    >code in the Combo box click event but when i go through the events, i dont
    >even find a trace of the procedure for combo click event being called. Any
    >ides or suggestions in this regard would be appreciated.
    >
    >Shravan



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