list box not getting populated

G

Guest

Hello All
My connection is working fine but I cannot populate my list box. When in debug mode I can see that I am looping through the table and I see all the values for myparent = rst.Fields("Parent_ID") but the list box doesn't populate. I have tried changing the RowSourceType from Table/Query to Value List and Field List. Only when the RowSourceType is set to Value List does something appear. However, only one value appears in the List Box from the table when I know there should be a lot more. I don't understand the problem. I would appreciate any help. Thanks in advance!

Dim con As ADODB.Connectio
Dim conString As Strin
Dim strSql_Parent As Strin

strSql_Parent = "SELECT Parent_ID FROM study_design
Set con = New ADODB.Connectio
conString = "Driver={SQL Server};Server=mgarg;DataBase=hello;Uid=;Pwd=;
con.connectionstring = conStrin
con.Ope
Set rst = New ADODB.Recordse
rst.Open strSql_Parent, con, adOpenForwardOnly, adLockReadOnly, adCmdTex
rst.MoveFirs
'Begin loo
Do While Not rst.EO

'Set myparent equal to the Parent_ID field of the Study_Design tabl
myparent = rst.Fields("Parent_ID"
List0.RowSource = myparen

Loo
rst.MoveNex

End Su
 
J

JeffW

mgarg,

Do you really need to open the recordset, or can you just populate the
listbox with SQL?
I'm thinking along the lines of:

strSql_Parent = "SELECT Parent_ID FROM study_design"
Me.List0.RowSourceType = "Table/Query"
Me.List0.RowSource = strSql_Parent

HTH,
Jeff

mgarg said:
Hello All,
My connection is working fine but I cannot populate my list box. When in
debug mode I can see that I am looping through the table and I see all the
values for myparent = rst.Fields("Parent_ID") but the list box doesn't
populate. I have tried changing the RowSourceType from Table/Query to Value
List and Field List. Only when the RowSourceType is set to Value List does
something appear. However, only one value appears in the List Box from the
table when I know there should be a lot more. I don't understand the
problem. I would appreciate any help. Thanks in advance!!
 
G

Guest

With the type of connection I am using, I have to open the recordset. i am designing front-end in access but i am connecting to sql server instead of access database. any help will be appreciated.thank
 

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