ListBox, error 424

C

coldmejl

Hi!

I´m trying to add items to a list box, using the following code:


Code:


ListBox1.Clear

While Not recordsetSales.EOF
ListBox1.AddItem (recordsetSales.Fields("product"))
recordsetSales.MoveNext
Wend


The problem is that I get 'Error 424: Object required', and I can´t
figure out why.

Any help appreciated! Thanks!

Edit: I want this code to be executed when the Excel document opens,
and have therfore out it in ThisWorkbook under the sub Workbook_Open().
If I use the same code on a CommandButton_click it works. Do I have to
specify in which sheet the listbox is situated or something?
 
Top