listbox

J

Jasper Recto

I have a list box that lists out names of reports that can be run. It is
linked to a table that has 3 fields.
Report Description
Report Name
Report Path

I have a button that executes a shell command that runs the program that the
reports are in.

How do I link the list box to the button? I want to be able to pass the
report name and report path to the button. The shell command is already
written to accept a generic report name and path but how do get the button
to know which item in the list box is selected?

Thanks,
Jasper
 
D

Dirk Goldgar

Jasper Recto said:
I have a list box that lists out names of reports that can be run.
It is linked to a table that has 3 fields.
Report Description
Report Name
Report Path

I have a button that executes a shell command that runs the program
that the reports are in.

How do I link the list box to the button? I want to be able to pass
the report name and report path to the button. The shell command is
already written to accept a generic report name and path but how do
get the button to know which item in the list box is selected?

Make sure that the list box includes all three columns from the table.
Make the Report Name be the bound column of the list box -- that way the
value of the list box will the name of the selected report. If you
don't want the list box to display all three columns, set the control's
ColumnWidths property so that the widths of unwanted columns are 0.

Now you can get the Report Name by referring to

Me.YourListBoxName

or

Me.YourListBoxName.Value

and you can get the Report Path by referring to

Me.YourListBoxName.Column(2)

Note that, in VBA, the columns of the list box are numbered from 0, so
that .Column(2) is actually the third column of the list box.
 

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