ADO recordsource as Combo box rowsource

I am using the code below to populate the rowsource of a combo box as a value list in an Access .adp database, the only problem is that there is a char limit to the value list property of the combo box. I am wondering if there is any way in which I can point the ADO.recordset directly at the combo box's rowsource property.

Code:
Dim cnn As New ADODB.Connection, rs As New ADODB.Recordset, strSource As
String, strString As String, pword As String
'create an ADODB connection to a Access2000 database
 cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= G:\IOS\Risk
Management\Risk Database\MFASRisk.mdb;"

'create an ADODB recordset using either pure sql or a query resident in the
remote Databse
 rs.Open "SELECT [*tblRisk].id, [*tblRisk].Title FROM [*tblRisk]", cnn, , ,
adCmdText

'set the record pointer to the first record in the recordset
        rs.MoveFirst
       
'create a loop to step through the open recordset until EOF is reached
  Do While Not rs.EOF
         'create a value list for the combo box
          strString = rs!id & "," & rs!Title
       
           rs.MoveNext
           strSource = strSource & strString & ";"
 Loop
 
'populate the combo box with the value list
    Combo0.RowSource = strSource


Many thanks,
Rob Tomey


rtomeyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nexusnationCommented:
what is wrong when you run the code? does something wrong happen?
0
PsychoDazeyCommented:
Why couldnt you just use:
Me.comboboxName.RowSource = RS after you open the connection to the recordset?  You would have to make sure you set the bound column property correctly so it displays the proper field from your query.  This code would have to be in the code behind your form, otherwise use:
Forms![FormName]!comboboxName.RowSource = RS
0
kraigCommented:
You could create a query and set the rowsource of the combo box to the query name (say 'qcboYourQuery').

Build the sql string the same way you are already, except use DBEngine(0)(0).QueryDefs("qcboYourQuery").SQL = strSource  in place of Combo0.RowSource = strSource.

You may need to requery the combo box (Me.Combo0.Requery).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

pbleightonCommented:
kraig's suggestion will work, but you can cut out a step and just:
Combo0.RowSource = "SELECT [*tblRisk].id, [*tblRisk].Title FROM [*tblRisk]"

Just make sure you have established a link to the table in the remote DB.
0
1WilliamCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept question, split points to PsychoDazey ,kraig  and pbleighton
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
1William
EE Cleanup Volunteer
0
nexusnationCommented:
duh... stupid me :-)

That 'Points For' Q will sink very quickly... pbleighton is not active. just an idea, but could you raise it to 60 pts and split it 3 ways?
0
nexusnationCommented:
^
0
1WilliamCommented:
I rec. sticking with RotaredoM desicion, no points change.  based on the question, questioner propbably would of split that way too, sorry pbleighton
0
nexusnationCommented:
okie dokie...

i just realized that when i typed "duh... stupid me :-)", i thought that *I* was the CV, not you ;-)
0
nexusnationCommented:
pbleighton,

You have one 'Points For' question that you can claim.
Please see http://www.experts-exchange.com/Databases/MS_Access/Q_20709976.html

Thanks,
Andrew
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.