Link to home
Start Free TrialLog in
Avatar of treyjeff
treyjeff

asked on

Data from access into combo box?

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.
Avatar of TheAnswerMan
TheAnswerMan

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


Avatar of treyjeff

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of TheAnswerMan
TheAnswerMan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial