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 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.
This is the code I am using:
Private Sub Print_Click()
Dim strReportName As String
Select Case Me.ContractType
Case "Electric"
Me!ContactID = ContactID
DoCmd.OpenReport "Electric"
Case "Gas"
Me!ContactID = ContactID
DoCmd.OpenReport "Gas"
Case "Oil"
Me!ContactID = ContactID
DoCmd.OpenReport "Oil"
Case "HeatPump"
Me!ContactID = ContactID
DoCmd.OpenReport "HeatPump"
Case "Cooling"
Me!ContactID = ContactID
DoCmd.OpenReport "Cooling"
End Select
End Sub
Could someone correct my errors. It’s getting frustrating.
Frank
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.
This is the code I am using:
Private Sub Print_Click()
Dim strReportName As String
Select Case Me.ContractType
Case "Electric"
Me!ContactID = ContactID
DoCmd.OpenReport "Electric"
Case "Gas"
Me!ContactID = ContactID
DoCmd.OpenReport "Gas"
Case "Oil"
Me!ContactID = ContactID
DoCmd.OpenReport "Oil"
Case "HeatPump"
Me!ContactID = ContactID
DoCmd.OpenReport "HeatPump"
Case "Cooling"
Me!ContactID = ContactID
DoCmd.OpenReport "Cooling"
End Select
End Sub
Could someone correct my errors. It’s getting frustrating.
Frank