how to assign rowsource to recordset?

G

Guest

Hi all
I am using access 2000 and sql server as backend. I want to populate a combo box with recordset values
my recordset contains 5 columns. some of the columns in the combobox will be hidden and 2 of them will be displayed in the combo. But the problem is that how to assign a recordset to combo box. usually we assign a querystring to rowsource but i didn't find any help or example which use recordsets in the rowsource.

Dim strSql As Strin
Dim conString As Strin
Dim con As ADODB.Connectio
Dim rst As ADODB.Recordse

strSql = "SELECT * FROM tblTeleList WHERE Active='Yes' ORDER BY tblTeleList.LastName

Set con = New ADODB.Connectio
conString = "Driver={SQL Server};Server=;DataBase=TelephoneListing;Uid=;Pwd=;
con.Properties("Prompt") = adPromptAlway

con.ConnectionString = conStrin
con.Ope

Set rst = New ADODB.Recordse
rst.Open strSql, con, adOpenForwardOnly, adLockReadOnly, adCmdTex
cmbLastName.RowSource = rst ----> i am not sure about this stmt
End Su

Any help will be appreciated.

Thanks
 
J

John Spencer (MVP)

Is there a reason you don't just assign strSQL directly to the combobox row source?

cmbLastName.RowSource = strSQL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top