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
125 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now