Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
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 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 February 28th, 2005, 12:40 PM
Authorized User
Join Date: Dec 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default filling a combo box from a data object

hi my names matt, please help me with this i know its simple but my brain has gone and i cant work it out.

i have a data object (data1) which is linked to a access data base called students.mdf. All i want to do is display the names held in the data base in the combo box so i can select which one

please give me a hand thankyou very much


Matthew Allee

Old March 1st, 2005, 08:08 AM
Authorized User
Join Date: Dec 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts

well im guessing no one had the awnser that dosent matter i feel mutch better after a good sleep and have done it. so for all of you wondering how to do it here you go. in public declerations set db as datavase and rs as recordset

Set db = Workspaces(0).OpenDatabase("Students.mdb") 'sets the database
Set rs = db.OpenRecordset("Students") 'sets the recordset to the database and the students feild
Set Data1.Recordset = rs ' sets the data object record set to the rs recordset

    With rs
        Do While Not .EOF 'while not end of file do
        Combo1.AddItem rs("FirstName") 'add the first name field from the recordset to the combo box
        .MoveNext 'go to the next line/record
    Loop 'do the top bit again until end of file
    .Close 'close
End With
db.Close 'close connection
End Sub

Similar Threads
Thread Thread Starter Forum Replies Last Post
Filling a combo box w/in datagridview kscase Visual Basic 2005 Basics 1 July 12th, 2007 07:26 AM
Combo Box can't find Object message PaulJH Access 5 April 13th, 2007 03:27 PM
filling a combo box using an array tware VB Databases Basics 0 September 21st, 2004 08:40 AM
Filling in a list box with data from Access goplayoutside VB Databases Basics 7 April 21st, 2004 08:27 PM
Combo Box - Data In Use MrDannyP Beginning VB 6 1 November 15th, 2003 10:37 AM

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