Event Question

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
 
R

Rick B

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
 
P

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

Joe Williams

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
 
R

Rick B

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
 

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