Listbox Rowsource

R

Rick Brandt

ScottS said:
Is it possible to change the rowsource for a listbox on a report
using VBA?

Pretty unusual to use a listBox in a report, but other than that you shoudl be
able to do it.

Me.ListBoxName.Rowsource = "SomeNewRowsource"

There is a good chance that you will not be able to do this in any event other
than report Open event though. You would have to test any others. Many things
like this that can be done on a form can only be done on a report in the open
event. Once the printing process starts they become read only.
 
F

fredg

Is it possible to change the rowsource for a listbox on a report using VBA?

Thanks.

Of what value would that be on a report?

Controls on a report are passive. You won't be able to select anything
from a list box on a report, and if it has a control source value, it
will show that row as selected and blacked out anyway.

Anyway, you can't set the rowsource of a List Box control once the
report is opened for printing or preview, other than in the report
Open event.
 
S

ScottS

Thanks for the response.

I wanted to use the list box because I like the way it displays the data. I
have a form where users enter lot numbers for defective materials. They scan
in as many lot numbers as they need to -- I display what they scan in on a
list box on the form.

I store all the lot number in a string to one field in my table. When I
need to display the lot numbers again on the form I set the rowsource
property of the form's list box to the string I stored and it displays just
fine.

I was hoping to do the same on the report but realize that this not
possible, however I do find it annoying that the list box control is
available for reports but you can't really control it. Fredg explains why in
the other response to my post.

I realize that I'll have to look for another approach.

Thanks again for your help.
 
S

ScottS

Thanks.

I wanted to use the list box for display purposes only. I use them a lot on
my forms.
 

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