Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

How give user an opportunity to exit a form

I have a form with one required field (in the table setup).  And I have the following code in the onclose event of the form.  But I want to give the user the opportunity to exit the form with no data entry if they want to do so.  Here is my code so far:

Private Sub Form_Close()

    If Nz(Me.txtCompanyName, "") = "" Then
        MsgBox "You must enter a company name!!!"
    Exit Sub
    End If

End Sub

How can I present them with a message box that will either let them stay in the form but return the focus to the txtCompanyName field, OR, let them leave the form with no data entry?
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial