Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Data from access into combo box?

Posted on 1998-10-03
Medium Priority
Last Modified: 2010-04-30
I am looking for easy code on how to get data from a field called "name" in an access database into 40 combo boxes.  So when the combo box drops down, it will contain all the names from the database.  Does anyone have easy code for this?  I'm using a dynaset.
Question by:treyjeff
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 1437960
I am Not sure about what you are asking..
You have 40 Combos, and Want to add one item from the list to each? <odd>
Or do you wand to add the Names to a combo box? <common>

I will try both...
'plop them into one combo where a user will select
Dim lr_resultset as RdoResultset
Set lr_resultset = AnyRdoConnect.OpenResultset("SELECT Name" _  
                 & "FROM NamesTable") 'a read only resultset
Do While Not lr_resultset.eof
   Combo1.Additem lr_resultset!Name & vbnullstring

'this is the second one.. again.. i cant think of why you want to do this.  ....assumes you have 40 combo box array
Dim lr_resultset as RdoResultset
dim x as integer
Set lr_resultset = AnyRdoConnect.OpenResultset("SELECT Name" _  
                 & "FROM NamesTable") 'a read only resultset
Do While Not lr_resultset.eof
   ComboArray(x).Additem lr_resultset!Name & vbnullstring
   x = x + 1   'you could use the lr_resultset.absoluteposition,
               'but this is faster
   if x > 39 exit Do    'Just in case some Jimbo added too many
                        'into the table



Author Comment

ID: 1437961
I need all names from the table into each of the combo boxes.  So if there are 2 or 20 it doesn't matter.  I'm using dynasets to move around in the database (eg. newdyn.movefirst) so I have no idea what the rdoconnect and the rest is for.

Accepted Solution

TheAnswerMan earned 60 total points
ID: 1437962
dim x as integer

Do While Not newdyn.eof
   for x = 1 to 40   'go through all the combos
      ComboArray(x).Additem Newdyn("Name") & vbnullstring

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question