Data from access into combo box?

Posted on 1998-10-03
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
  • 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 30 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

809 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