Listbox

  • Thread starter Thread starter stelios
  • Start date Start date
S

stelios

Hi,
I have the following code to fill a list box:

With RSSerchKartela
.MoveLast
.MoveFirst
Do Until .EOF
Me.[lstResults].Column(0) = KartID
Me![lstResults].Column(1) = !AM
Me![lstResults].Column(2) = !Kathgoria
Me![lstResults].Column(3) = !Bathmos
Me![lstResults].Column(4) = !Epwnymo
Me![lstResults].Column(5) = !Onoma
Me![lstResults].Column(6) = !Patronymo
.MoveNext
Loop
Me.txtCount.Value = .RecordCount
End With

But I don't get results, I get a run time error ('424' an object required)!
Whats going wrong?
What I have to change for filling the list box?

stelios
 
You cant fill a list box from code this way.

The simple way is just to set the recordsource of the listbox to the name of
a query returning the records you want. Then you dont need any looping
through the recordset at all.
So if your query was named myListQuery and its SQL was:
SELECT KartID,AM,Kathgoria,... etc FROM Yourtablename ... etc

then just
me.lstResults.recordsource = "myListQuery"

would fill the list automatically.

There are methods for filling a listbox when the data is not in a table, but
it can be tricky.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
Add the code

Me.lstResults.Requery

To the end of your code and see if it works...

If it doesn't then you'll have to come up with an
alternative way of creating data, then refresh the List
Box.

Tony C.
 
Back
Top