Solved

Data from access into combo box?

Posted on 1998-10-03
3
114 Views
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.
0
Comment
Question by:treyjeff
  • 2
3 Comments
 
LVL 3

Expert Comment

by:TheAnswerMan
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
   lr_resultset.movenext
loop


'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
   lr_resultset.movenext
   if x > 39 exit Do    'Just in case some Jimbo added too many
                        'into the table

loop


0
 
LVL 1

Author Comment

by:treyjeff
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.
0
 
LVL 3

Accepted Solution

by:
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
   newdyn.movenext
loop
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

810 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