Report List Box

S

Shelly Jackson

Someone posted this sort of question below but I am still I'm stuck.

I created a table, tblReports, with two fields: ID and RptName. I manually
entered the names of my reports of my reports into the table.

I then created a form bound to tbleReports. I put in a list box listing
RptName from tbleReports.

Now I am attempting to write code for the Command Button beside the my
RptListBox that will open up the report that the user selects.

But, how do I tie the report names I typed into the table and the actual
reports?

TIA

S. Jackson
 
F

Fredg

Shelly.
You do not need to make a form using the report table as recordset.
You do not need a command button to open the reports.
You can use what ever form is usually open when the reports are to be run.

Add a Combo or a ListBox to the Form.
I'm going to use the Combo box, but everything is the same for a List Box.
Question: Are the names you entered into the table the
actual report names ("rptSalesEndOfMonth") or a more user
friendly name (such as "End of the Month Sales Report")?

If it's the actual report name, set the Combo Box record source to:
Select [RptName] from TableReports Order by [RptName];

Set the Combo Box Bound column property to 1
Set the Column Count property to 1
Set the Column Widths property to 1"
(or wide enough to show the longest name").

Then code the After Update event of the Combo Box:

DoCmd.OpenReport ComboBoxName, acViewPreview


If the report names stored in the Table are the user friendly names,
you'll need to add another field named [ActualName].
Fill it in with the appropriate actual report name,
so that you now have both the user friendly and the actual report names.

Then code the Combo Box RowSource:
Select [RptName], [ActualName] From TableReports Order by [RptName];

Set the bound column property of the combo box to 2
Set the Column Count property to 2
Set the column width's property to 1";0"

Code the AfterUpdate event the same as the above....
DoCmd.OpenReport ComboBoxName, acViewPreview

Simply clicking on the report name will then open the report.
No special form, no command button.

If you feel you absolutely must have a command button, do every
thing the same except, INSTEAD of coding the Combo Box AfterUpdate
event, use that same code in the command button click event.
 

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

Similar Threads

List Box in a Dialog Form 3
More Help Needed - Report Objects 3
Help with strSQL 12
Requery Method 1
2 List Boxes-1 Form 1
report name 2
Trouble generating Filter for emailing report... 2
Launching a Report 1

Top