Code to prevent user from opening report?

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
 
W

Wayne Morgan

.....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.
 

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