0

If there a way to re-open a form that is being closed without Access overloading?

I've got a Modal Form that I want the user to fill out and don't want them to leave that screen until that data is filled.

I've tried just re-opening the form that they're trying to close, but it overloads Access and wont let me do anything at all after that

1 Answer 1

2

You can cancel the closing of the form by setting Cancel = True in the OnUnload event.

Private Sub Form_Unload(Cancel As Integer)

    If Not CheckAllDataIsFilled() And Not bCancelButtonClicked Then
        MsgBox "Please fill out all data.", vbExclamation
        Cancel = True
    End If

End Sub

But you should always provide a way of canceling the form, or users will get very upset with you, and they won't refrain from killing Access via Task Manager if there is no other way.

Sign up to request clarification or add additional context in comments.

2 Comments

Does this work on the close button? Maybe I should have clarified that...
Yes, it does. And on Alt+F4 and Docmd.Close etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.