print different report based on value in control

G

Guest

I have a form for data entry and I want to add a command button that will
print a one of 2 reports for the current record. What determines the report
is the value in the field FrameQty. If the value is 6 then I want to print
Traveler6, if the value is 4 then I want to print Traveler4. Help is
appreciated.
 
F

fredg

I have a form for data entry and I want to add a command button that will
print a one of 2 reports for the current record. What determines the report
is the value in the field FrameQty. If the value is 6 then I want to print
Traveler6, if the value is 4 then I want to print Traveler4. Help is
appreciated.

Code the command button's click event:

If Me.FrameQty = 4 or Me.FrameQty = 6 then
DoCmd.OpenReport "Traveler" & Me.FrameQty
End If
 
G

George Nicholson

I would use a Select Case statement because its easiest to change when (not
if) you add reports/options in the future:

Select Case FrameQty
Case 4
DoCmd.OpenReport "Traveler4"
Case 6
DoCmd.OpenReport "Traveler6"
Case Else
MsgBox "Unexpected Value"
End Select
 

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