One Command button for different reports

  • Thread starter Francis Cunningham, Jr.
  • Start date
F

Francis Cunningham, Jr.

I have two controls, among others, on a particular form. One control
‘ContractNumber’ represents the specific customer (their phone number) and
the ‘ContractType’ which represents the specific report. I have 5 reports,
none of the reports are the same. Based on the ‘ContractNumber’ I would like
to have a command button open the ‘ContractType’ for the particular customer.
I realize I can have command buttons, one for each report and have a
parameter query use the ‘ContractNumber’ to call up the specific report. I
want one button to open different reports, say ‘Click to view customers
Contract’. The one command button would pick the correct customer and their
specific contract.
The reports are named: Gas, Electric, Oil, HeatPump and Cooling.
The ContractNumber is actually the customers phone number.
The ContractType’s are: Gas, Electric, Oil, HeatPump and Cooling.
Can anyone help. I have been laboring for months with this.
 
J

Jeff Boyce

Francis

Using a different command button for each report means serious maintenance
work! What happens if you or your customer decides to add two new reports,
or discontinue using one? Your form can get pretty cluttered by adding all
those buttons.

Another approach is to use a single command button to open the report (I
usually do mine in print preview mode). Then I add a combobox in which I
display all the available reports. Pick a report from the combobox, launch
it with the command button.

Would that work in your situation?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
M

Marshall Barton

Francis said:
I have two controls, among others, on a particular form. One control
‘ContractNumber’ represents the specific customer (their phone number) and
the ‘ContractType’ which represents the specific report. I have 5 reports,
none of the reports are the same. Based on the ‘ContractNumber’ I would like
to have a command button open the ‘ContractType’ for the particular customer.
I realize I can have command buttons, one for each report and have a
parameter query use the ‘ContractNumber’ to call up the specific report. I
want one button to open different reports, say ‘Click to view customers
Contract’. The one command button would pick the correct customer and their
specific contract.
The reports are named: Gas, Electric, Oil, HeatPump and Cooling.
The ContractNumber is actually the customers phone number.
The ContractType’s are: Gas, Electric, Oil, HeatPump and Cooling.
Can anyone help. I have been laboring for months with this.


The code for your button could be like:

Dim stWhere As String
stWhere = "ContractNumber=""" & Me.PhoneNum & """"
DoCmd.OpenReport Me.ContractType, acViewPreview, , stWhere
 

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