Solved

Data from access into combo box?

Posted on 1998-10-03
3
111 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now