Solved

I am looking for code to import data from a MDB table to dropdown list combo (read from access and show the list in combo)

Posted on 2004-10-01
3
128 Views
Last Modified: 2010-05-02
Kindly suggest me a code that i can use to get data from an mdb table from a combo drop down list.
Read from access and show the list in combo.
0
Comment
Question by:gopinair
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 20 total points
ID: 12204125
This should do it.  You'll need to edit the code below and insert the name and location of your database, the name of the table you want to read from, and the name of the field you want to isnert into the combobox.

    'Include a reference to Microsoft ActiveX Data Objects 2.x Library
    Dim adoCon As New ADODB.Connection, _
        adoRS As New ADODB.Recordset
    adoCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\MyDb.Mdb;Persist Security Info=False"
    adoCon.CursorLocation = adUseServer
    adoCon.Open
    adoRS.Open "MyTable", adoCon, adOpenDynamic, adLockReadOnly, adCmdTableDirect
    While Not adoRS.EOF
        Combo1.AddItem adoRS.Fields("MyField")
        adoRS.MoveNext
    Wend
    adoRS.Close
    adoCon.Close
    Set adoRS = Nothing
    Set adoCon = Nothing
0
 
LVL 76

Expert Comment

by:David Lee
ID: 12561325
Accept BlueDevilFan.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question