Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB Databases
|
Pro VB Databases Advanced-level VB coding questions specific to using VB with databases. Beginning-level questions or issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 1st, 2004, 10:11 AM
Authorized User
 
Join Date: Jun 2003
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:

  .MoveFirst
  Do
    Combo1.AddItem .Fields("Username").Value
    Combo1.ItemData(Combo1.NewIndex) = .Fields("Ident").Value
    .MoveNext
  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,

Paul
 
Old October 23rd, 2004, 10:11 AM
Aal Aal is offline
Authorized User
 
Join Date: Oct 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this code :
--- first set your recordset vars ----------
I assume the Rec Var with --> RC
--------------------------------------------
strSQL = "select * from Users order by Name"
rc.Open strsql,cn,2,1

if not rc.EOF then
   combo1.Clear
   rc.movefirst
      while not rc.EOF
            combo1.additem rc!username
            rc.movenext
      wend
   set rc = nothing
end if






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 02:24 PM
Populate Combo Box phil.t Access 3 November 18th, 2004 03:39 AM
Populate combo box with access db with using ADO neo_jakey VB Databases Basics 3 October 13th, 2004 03:36 PM
Populate combo box with access db with using ADO neo_jakey Beginning VB 6 1 September 28th, 2004 02:07 AM
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.