Event Question

  • Thread starter Thread starter Joe Williams
  • Start date Start date
J

Joe Williams

I have a form with two buttons: PRINT and CLOSE. The form also has the X in
teh upper right hand corner of the form.

I would like to create a function that validates all of the field
information prior to either one of these actions to happen.

I have read a post about creating an integer value that you can set if the
form's information is valid or not, but I am not sure how to use it.

My question is, what do I need to do to make sure the form cannot be closed,
printed, or even change records unless all the form's fields are entered
correctly?

Thanks

Joe
 
In the form's close event, you can do whatever validations you need. If
they fail have the following line....

Cancel = True
(This will stop the form from closing)

You'd have to put similar code in the before update events and tie it to
your "print button".

Rick B
 
Consider disabling the 'X' by changing the forms Control Box property to No
(to remove the X) or the Close Button to No (to grey out the X)

Then your users are forced to use one of your command buttons, then
following Rick's suggestion, run your validation then close the form.
 
Thanks

I did this and there is one problem - If the user is adding a record and
then just wants to exit, now they are not able to close the form becuase the
close button is gone and it will not let them proceed without validating
thier entries (meaning fields cannot be null, etc)

How do I give them an "out" from the form and to not save the record?

Thanks

Joe
 
Before the cancel you would need to pop up a message box and ask them if
they wish to abort. Then branch to the proper place in your code. Either
do the "cancel=true" line, or exit the sub.

Rick B
 
Back
Top