Print preview depending on a field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I've done some research and can't quite find the answer to my question. I
have a combo box (cboXYZ) on a form I created and with two options (A and B).
There is a button at the bottom of the form which I would like to print
preview a report. If A is selected then I would like to bring up report Aa
and if B is selected bring up Bb.

Any help would be appreciated!

---Achilles
 
You can use:

me.Refresh
if me.cboXYZ = "A" then
docmd.OpenReport "Aa",acViewPreview
end if
If me.cboXYZ = "B" then
docmd.OpenReport "Aa",acViewPreview
end if
 
I assume your two options are part of an Option Group - that control has a
name. Each of the options has a value associated with it 'A' may be 1 and
'B' may be 2. You can confirm these details by looking at the properties
for each item.

In your command button's On Click event property...

Select Case Me.OptionGroupName
Case 1
DoCmd.OpenReport "Aa", acViewPreview
Case 2
DoCmd.OpenReport "Bb", acViewPreview
End Select
 
Back
Top