One Command button for different reports

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

Francis Cunningham, Jr.

How do I call up a specific report based on 2 fields on a form with a command
button.
To explain myself. I already have the form made, and on the form are the
fields ContactID and ContractType. I would like the create a command button
on this form and when clicked it would open the report based on the ContactID
and Contracttype (on the report will be the contacts mailing info, and the
correct contract will be chosen because of the Contracttype) there are 5
report possibilities. The ContactID and Contracttype are fields on two
different tables.

I have 5 reports, each design is different. I would like the form field
‘Contracttype’ determine which report opens. The ContactID will supply the
mailing address.
For example:
ContractType=Gas then print Report ‘Gas’
ContractType=Electric then print Report ‘Electric
ContractType=Heat then print Report ‘Heat’ and so on.

If I can get some help with the first two lines and how to finish the code I
am most appreciative.
Frank
 
M

mscertified

In the OnClick event for the command button insert some code to test the
value of the other control. You can pass a value to the report via the
OpenArgs. You can research OpenArgs via Access Help.
OnClick event:
Select case Me!ContractType
Case "Gas"
DoCmd.OpenReport "Gas", , , , , Me!ContactID
Case "Heat"
DoCmd.OpenReport "Heat", , , , , Me!ContactID
etc. etc.
End Select

-Dorian
 
F

Francis Cunningham, Jr.

When writing the following code I get a error message. "Run time error 438,
Object does not support this property or method."
I don't know how to write code so I don't know If the , , , , , mean
anything.
and I don't know how to end the code. If I knew the first full section and
the last section I can fill in the middle.
Frank
 

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