Pop-up Error Messages

  • Thread starter Thread starter rbaxter
  • Start date Start date
R

rbaxter

Does anyone know how to generate a pop-up message when exiting a form
if 'txtFieldA' is left blank (""), that reads:

"Please fill in txtFieldA."

Thank
 
Best to have a button for exiting so that you can control it. The code
behind the button would be something like

Private Sub cmdExit_Click()

If txtFieldA.Text = "" Then
MsgBox "Must input this field"
With txtFieldA
.SelStart = 1
.SetFocus
End With
Else
Me.Hide
End If

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
You could use the Userform_QueryClose event, which is
fired when the form is closed.
 

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

Back
Top