Calling up a specific report with a command button

  • 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?

To explain myself. I already have the form made, and on the form are the
fields CustomerID and ContractID. I would like the create a command button
on this form and when clicked it would open the report based on the
CustomerID and ContractID there are 4 or 5 report possibilities. The
CustomerID and ContractID are fields on two different tables.

I have 5 reports, each design is different. I would like the form field
‘ContractID’ determine which report opens to print or preview.
For example:
ContractID=Gas then print Report ‘Gas’
ContractID=Electric then print Report ‘Electric
ContractID=Heat then print Report ‘Heat’ and so on.

If anyone can help me with this I am greatly appreciative.
Frank
 
D

Dorothy

How do I call up a specific report based on 2 fields on a form?

To explain myself. I already have the form made, and on the form are the
fields CustomerID and ContractID. I would like the create a command button
on this form and when clicked it would open the report based on the
CustomerID and ContractID there are 4 or 5 report possibilities. The
CustomerID and ContractID are fields on two different tables.

I have 5 reports, each design is different. I would like the form field
'ContractID' determine which report opens to print or preview.
For example:
ContractID=Gas then print Report 'Gas'
ContractID=Electric then print Report 'Electric
ContractID=Heat then print Report 'Heat' and so on.

If anyone can help me with this I am greatly appreciative.
Frank

Hi Frank. You can go into the "After Update" line of the Properties
for the ContractID field and choose "Event Procedure". When you get
there, you can write a VBA code that's an IF/THEN statement.

So for example, in the code, you would have something like this.

If ContractID = "Gas" then
docmd.openreport "Gas", acnormal
else
if ContractID = "Electric" then
docmd.openreport "Electric"
else...

Hope this helps.

Good luck.

Dorothy
 

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