Randy said:
I had an idea that it would be nice to select a particular query or reports
from a combobox. I would like all my queries or reports, lets say 10,
listed in a combobox, select the query/report and have it fire. Is this
possible? How would I do this..Thanks..Randy
Hi, Randy
There are many ways to do what you want; this is the method we use.
All of the reports that are available all begin with "+R: *" (without the
quotes).
So the report name would be like: +R: StatementByMth and if it wasn't ready
to be used yet, the name would be: StatementByMth
Create an unbound form. Add any unbound control for any parameters you need.
Add an unbound listbox; we named it "lstReports". We use a listbox because
it is easier to see the reports - one less click.
The list box row source is a query; the SQL looks like this:
SELECT msysobjects.Name
FROM msysobjects
WHERE (((msysobjects.Name) Like "+R: *"))
ORDER BY msysobjects.Name;
Below the list box is a button with the caption OPEN. The click event is:
Private Sub cmdOpen_Click()
On Error Resume Next
DoCmd.OpenReport lstForm, acViewPreview
On Error GoTo errHandler
errHandler:
End Sub
There are also two events for the list box OnClick and OnDoubleClick. The
OnClick enables the button (default is Enabled=False). Double clicking a
report in the list box runs the report, just like clicking once on a report,
then clicking the OPEN button.
The code for the click events is:
Private Sub lstReport_Click()
cmdOpen.Enabled = True
End Sub
Private Sub lstReport_DblClick(Cancel As Integer)
cmdOpen_Click
End Sub
That is all it takes....
HTH,
Steve