Programming a Command button

  • Thread starter Francis Cunningham, Jr.
  • Start date

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.

Roger Converse

If then statement for when you click the 'ContractType' button based on the


If ContractNumber = 1 then docmd.openreport "Gas"
Elseif ContractNumber = 2 then docmd.openreport "Water"
End if

A case statement should work as well.

You could also change your report options to a combo box if there are only
five and then the user could choose the report based on the combo 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