Code to prevent user from opening report?

  • Thread starter Thread starter Paul Johnson
  • Start date Start date
P

Paul Johnson

I have a report that needs to have a form open first, in order for the right
set of values to be read into the report. I have put a command button on the
form that opens the report, but I would also like to put some code-- I
guessed it would be in the report's _Open event-- that would abort the
opening if the form wasn't open, to keep users from opening the report right
from the database window.

I can see if the form is open using If Not
SysCmd(acSysCmdGetObjectState, acForm, stDocName) , but I don't know how to
abort the report opening.

Any ideas?

TIA,

Paul Johnson
Alexandria, VA
 
.....Then Cancel = True

If this is done in the report's Open event, setting Cancel to True will cancel the open.
However, you may prefer to pop open the needed form instead. If you open the form with the
acDialog Window Mode argument it will pause the report's code until you close or hide the
form (hide it if you still need it open to read data from). To hide it, set the form's
Visible property to False. Remember to close the form when you close the report, if you
are through with it.
 
Back
Top