Maldred
Maldred

Reputation: 1104

Open a Closed Form VBA Access

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

Upvotes: 0

Views: 299

Answers (1)

Andre
Andre

Reputation: 27634

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.

Upvotes: 2

Related Questions