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

You are currently viewing the VB Databases Basics 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:09 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 September 12th, 2004, 12:23 PM
Registered User
 
Join Date: Aug 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to bumon007
Default

sorry i can't help u in these regard

monideep
 
Old September 29th, 2004, 09:38 AM
Authorized User
 
Join Date: Sep 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Lalit_Pratihari
Default

Hi,

Your script is ok just add WITH..END WITH clause.

Thanks,

Lalit
Life Means More...;)
 
Old October 13th, 2004, 03:36 PM
Authorized User
 
Join Date: Oct 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jolzy
Default

'Try this
'-------------------------------------------------
'lets say your recordset called "RS"
'--------------------------------------------------

App.Path & "\despatcher97.mdb"

strSQL = "select * from Users order by Name"

with RS

  .MoveFirst
  Do
    Combo1.AddItem .Fields("Username").Value
    Combo1.ItemData(Combo1.NewIndex) = .Fields("Ident").Value
    .MoveNext
  Loop Until .EOF
End With

'happy coding :)






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 Pro VB Databases 1 October 23rd, 2004 10:11 AM
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.