VB6 retrieving MSAccess all records in VB6 ComboBox

45 pts.
Tags:
ComboBox
Microsoft Access
Microsoft Access ComboBox
VB 6
VB 6.0
Visual Basic
Im beginner to VB6 and I have project to buildup company Database, I will be so grateful if anybody could help me in that: "How can I get all records of any field of MSAccess database in ComboBox or ListBox of VB6

Answer Wiki

Thanks. We'll let you know when a new response is added.

Please provide a little more information:

- Do you know how to connect to the database ? are you able to do it ?
- Do you know how to retrieve data from the database ?
- Are you going to use a data control or do you want to do this programmatically ?

Please let us know what you have done so far, so we can focus on your specific problem/doubt.

Sorry for delay, I got busy in my exams, Okay dear sir, let me cover all of your question, pls see below:

- Yes, I know how to connet to the Access Database and I’ve done it.
- Yes, I know how to retrieve the data from the Access Database.
- Yes, Im using Data Control but I like in both way, through Data Control and also Programmatically.

Let me give you some scenario, Im using Data Control and using ComboBox for searching Records.

I want to get all the records of the field in ComboBox dropdown list from MSAccess Table. So when I select any record randomly from the ComboBox dropdown list, it fetch the complete record.

Thanks for responding, please feel free if you want to know more about this query.

Bye :)

Discuss This Question: 10  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    You could use this code to populate the combo (this is for Sql Server, so the connection string should be modified as needed)
    Dim adoConnection As ADODB.Connection
    Dim adoRecordset As ADODB.Recordset
    Dim connectString As String
    
    '-Create a new connection --
    Set adoConnection = New ADODB.Connection
    '-Create a new recordset --
    Set adoRecordset = New ADODB.Recordset
    
    '-Build the connection string to use when we open the connection --
    'connectString = "Data Source=sql;Database=test;Uid=your_username; Pwd=your_password;"
    
    adoConnection.Open connectString
    'adoRecordset.Open "SELECT field_x FROM table_x", adoConnection
    
    ' Populate the combo
    Do Until adoRecordset.EOF
        Combo1.AddItem adoRecordset!user_id
        adoRecordset.MoveNext
    Loop
    Then, to show the complete records you could add a data grid and an ADODC control to use as data source (although this could also be done programmatically as above), and put some code similar to the following in some event of the combo (click event, for example), to show the records related to the value selected from the combo:
    Adodc1.RecordSource = "SELECT * from table_x where field_x ='" & Combo1.Text & "'"
    Adodc1.Refresh
    Feel free to ask if this is not clear enough.
    68,735 pointsBadges:
    report
  • Ohailo
    hi can i ask for a help??? i want a combo box that will retrieve the information in my ms access.If i save or delete record it will be listed there when i scroll down the combo box..can you help me please?
    10 pointsBadges:
    report
  • carlosdl
    Ohailo, please create a new question, and provide more information about your problem and the software your are using. Are you using VB ? what version ? Do you know how to connect to the database ? What is your specific doubt/problem ?
    68,735 pointsBadges:
    report
  • Blamer00
    hi im newbie here..
    20 pointsBadges:
    report
  • Blamer00
    i'm developing a program and i use vb6.0,,my question is how can i retrieve a data from a datagridview and display it in a textbox?? without using ADODC..i prefer ADODB only..any suggestions??? thank you so much..
    20 pointsBadges:
    report
  • PAULIN
    how to code save using vb 6.0 and connect to wamp server?
    15 pointsBadges:
    report
  • Kawa23
    dear my friends please can someone help me in my codes,my code is adodc1.recordsourse="select * from table2 where name="'&text2&'"" adodc1.commandtype=adcmdtext adodc1.refresh but the computer give me the message that my code is not right,massage is (compile error: expected : end of statement) please help me.
    10 pointsBadges:
    report
  • carlosdl
    Kawa23, you should create a new question. In your new question, please include information about your VB version and operating system, and include your whole code. Also, let us know the line of code that the compiler marks as erroneous.
    68,735 pointsBadges:
    report
  • Abbly
    Hi guys, I have a question regards on visual basic 6. I made some project and finally when am going to Packaging the program, the software didn't work properly. the problem is the path of the database. I created the connection using adodc component. Can you help me to fix this problem? Thanks,
    15 pointsBadges:
    report
  • Abdulla362
    :(
    10 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following