list box control - inserting data into columns

  • Thread starter Thread starter SirPoonga
  • Start date Start date
S

SirPoonga

I am trying to output some data from a SQL query to a list box control
in Access.

My listbox is named listNames. When I try the following code I get an
error message on the line with '***. The message says "Run-time error
'424' Object Required"


sqlcmd = "SELECT First, Last " & _
"FROM Names"

rs2.Open sqlcmd, CurrentProject.Connection
If Not rs2.EOF Then rs2.MoveFirst
ii = 0
Do While Not rs2.EOF
listNames.Column(0, ii) = rs2.Fields(0) '***
listNames.Column(1, ii) = rs2.Fields(1)
rs2.MoveNext
ii = ii + 1
Loop
rs2.Close
 
I am trying to output some data from a SQL query to a list box control
in Access.

My listbox is named listNames. When I try the following code I get an
error message on the line with '***. The message says "Run-time error
'424' Object Required"


sqlcmd = "SELECT First, Last " & _
"FROM Names"

rs2.Open sqlcmd, CurrentProject.Connection
If Not rs2.EOF Then rs2.MoveFirst
ii = 0
Do While Not rs2.EOF
listNames.Column(0, ii) = rs2.Fields(0) '***
listNames.Column(1, ii) = rs2.Fields(1)
rs2.MoveNext
ii = ii + 1
Loop
rs2.Close

make first a debug.print rs2.Fields(0)

if this works then it is an error with your listNames
If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message
MW
 
I found out what was going on. Listbox needs to be bound. So I just
figured out a SQL statement to assign tot he row source for what I
needed. Thanks.
 

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

Back
Top