Close report action based on criteria

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

Guest

I have a form that populates the fields of two reports, one that prints or
previews a letter and the other that prints or previews a corresponding
envelope. The close action of the letter reports returns to the form whether
the user previews or prints it, in order to print the envelope. As it is now,
the close action on the report to print the envelope closes the underlying
form and brings up the database's switchboard.

Long story short...(!)

Is there any way I can have the close action of the report look to whether
it was open in acPreview or acPrint? I would like the user to be taken back
to the form if the report was previewed and back to the switchboard if it was
printed.

Thank you in advance for any advice you may have to give.
 
B:

The On Activate event fires in a report only if it is previewed. So, you
could do the following:

1.) Dimension a variable in the report's general section of its module e.g.

Dim boolOpenPreview as boolean

2.) In the On Activate event set the variable to True to indicate that its
been previewed:

boolOpenPreview = True

3.) In the On Close event run code like this:

If boolOpenPreview = False then
Forms!NameOfReportForm.Close
Forms!NameOfSwitchBoardForm.SetFocus
Else
Forms!NameOfReportForm.SetFocus
End if

HTH
 
Steve,
Thank you for your ideas. Beautifully simple...execpt (my apologies) I
didn't mention that the report is not sent directly to the printer even by
the Print option button on the form. A message box opens and reminds users to
make sure that an envelope is loaded into the printer.

<blush>

Is there some way I could have the declared boolean look to which of the
command buttons the report was launched from?
--
BJM
ACE Assistant
Gary Allan High School


SA said:
B:

The On Activate event fires in a report only if it is previewed. So, you
could do the following:

1.) Dimension a variable in the report's general section of its module e.g.

Dim boolOpenPreview as boolean

2.) In the On Activate event set the variable to True to indicate that its
been previewed:

boolOpenPreview = True

3.) In the On Close event run code like this:

If boolOpenPreview = False then
Forms!NameOfReportForm.Close
Forms!NameOfSwitchBoardForm.SetFocus
Else
Forms!NameOfReportForm.SetFocus
End if

HTH
 
Back
Top