opening different reports from the same form

G

Guest

I have a "customerEntry" form where I have a drop down list to choose either
Residential or Comercial. This entry determines which report to print. I
have 2 reports "CProposal" and "RProposal" that are formatted differently.
I currently use two different comands buttons to print one ore the other
report. I would like just one.
Each comand looks like this

Dim stDocName As String

stDocName = "reportname"
DoCmd.OpenReport stDocName, acNormal, , "[ID]=" & Me!ID

Any help would be great
Thanks
Mike
 
A

AlCamp

Mike,
Many ways to do that...

If [YourCombo] = "Residential" Then
DoCmd.OpenReport "RProposal", acNormal, , "[ID]=" & Me!ID
Elseif [YourCombo] = "Commercial" Then
DoCmd.OpenReport "CProposal", acNormal, , "[ID]=" & Me!ID
End if

Or... use a Select Case statement.

hth
Al Camp

mcast said:
I have a "customerEntry" form where I have a drop down list to choose
either
Residential or Comercial. This entry determines which report to print. I
have 2 reports "CProposal" and "RProposal" that are formatted
differently.
I currently use two different comands buttons to print one ore the other
report. I would like just one.
Each comand looks like this

Dim stDocName As String

stDocName = "reportname"
DoCmd.OpenReport stDocName, acNormal, , "[ID]=" & Me!ID

Any help would be great
Thanks
Mike
 
G

Guest

Thanks Al

I still have a problem though.
When I use the print comand button I get a screen asking me to enter
paramater value. I can enter past without entering a parameter and report
prints fine. How do I get rid of this prompt?
Also I do not have this problem with print envelope comand. The comands are
identicle except for the report name.
Thanks
Mike
AlCamp said:
Mike,
Many ways to do that...

If [YourCombo] = "Residential" Then
DoCmd.OpenReport "RProposal", acNormal, , "[ID]=" & Me!ID
Elseif [YourCombo] = "Commercial" Then
DoCmd.OpenReport "CProposal", acNormal, , "[ID]=" & Me!ID
End if

Or... use a Select Case statement.

hth
Al Camp

mcast said:
I have a "customerEntry" form where I have a drop down list to choose
either
Residential or Comercial. This entry determines which report to print. I
have 2 reports "CProposal" and "RProposal" that are formatted
differently.
I currently use two different comands buttons to print one ore the other
report. I would like just one.
Each comand looks like this

Dim stDocName As String

stDocName = "reportname"
DoCmd.OpenReport stDocName, acNormal, , "[ID]=" & Me!ID

Any help would be great
Thanks
Mike
 
A

AlCamp

MCast,
Why didn't you include the parameter message Access is asking for...
what's the exact prompt for the parameter?

Your Parameter has to be in the query for the report, or within a control
on the report itself.
You'll have to go thru each item in the query to find the parameter (or
mispelled control name or mispelled variable), and thru each item on your
report. There's just no other way around it.

For example, if Access prompts for parameter "XYZ123", then "XYZ123" must
be mentioned somewhere in the report query or somewhere in a control or
grouping or in the code in the report itself.
hth
Al Camp

mcast said:
Thanks Al

I still have a problem though.
When I use the print comand button I get a screen asking me to enter
paramater value. I can enter past without entering a parameter and report
prints fine. How do I get rid of this prompt?
Also I do not have this problem with print envelope comand. The comands
are
identicle except for the report name.
Thanks
Mike
AlCamp said:
Mike,
Many ways to do that...

If [YourCombo] = "Residential" Then
DoCmd.OpenReport "RProposal", acNormal, , "[ID]=" & Me!ID
Elseif [YourCombo] = "Commercial" Then
DoCmd.OpenReport "CProposal", acNormal, , "[ID]=" & Me!ID
End if

Or... use a Select Case statement.

hth
Al Camp

mcast said:
I have a "customerEntry" form where I have a drop down list to choose
either
Residential or Comercial. This entry determines which report to print.
I
have 2 reports "CProposal" and "RProposal" that are formatted
differently.
I currently use two different comands buttons to print one ore the
other
report. I would like just one.
Each comand looks like this

Dim stDocName As String

stDocName = "reportname"
DoCmd.OpenReport stDocName, acNormal, , "[ID]=" & Me!ID

Any help would be great
Thanks
Mike
 

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