Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old September 1st, 2004, 10:10 AM
Authorized User
Join Date: Jun 2003
Location: Mexico City, Distrito Federal, Mexico.
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default Populate combo box with access db with using ADO

I am very new to making VB applications although I have a fair amount of experience with ASP. I want to populate a dropdown combo box with all the users in my database which is situated in the same directory as the application.

I am unsure of the coding but I would assume that you would have to locate the db like:

App.Path & "\despatcher97.mdb"

and the SQL statement would be as follows:

strSQL = "select * from Users order by Name"

and with my experience with ASP I assume the population part would be something like:

    Combo1.AddItem .Fields("Username").Value
    Combo1.ItemData(Combo1.NewIndex) = .Fields("Ident").Value
  Loop Until .EOF

I am just unsure how you would fit it all together.
Any help with this matter would be greatly received.

With many thanks for your time and assistance,

Reply With Quote
  #2 (permalink)  
Old September 28th, 2004, 02:07 AM
Friend of Wrox
Join Date: Sep 2004
Location: New Delhi, Dekhi, India.
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Anantsharma Send a message via Yahoo to Anantsharma

Well friend u r going very correct.

Its better to use DSN to connect to mdb file. It gives the freedom to keep ur mdb file anywhere in network and locate the database through DSN. If r not aware of DSNs, see in Win 2000 help "creating DSN".
If u r using connectionstring ("Provider=Microsoft.jet.7.0,database=......). U have to provide the path of mdb file in the way u have mentioned.

Public Sub FillCombo()
 dim Rs as New ADODB.RecordSet
 Set Rs = Conn.Execute("Select Name From Users Order by name")
    Do while Rs.Eof()=False
       Combo1.AddItem Rs("Name") & ""
    Set Rs = Nothing
End Sub

Hope this helps.

B. Anant
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate a text box from a combo box value dnf999 Access VBA 7 February 6th, 2012 01:24 PM
Populate Combo Box phil.t Access 3 November 18th, 2004 02:39 AM
Populate combo box with access db with using ADO neo_jakey Pro VB Databases 1 October 23rd, 2004 10:11 AM
Populate combo box with access db with using ADO neo_jakey VB Databases Basics 3 October 13th, 2004 03:36 PM
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM

All times are GMT -4. The time now is 04:32 AM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.