Can I take control of implicit Saves?

  • Thread starter Thread starter Stapes
  • Start date Start date
S

Stapes

Hi

I am setting up forms for data entry. When the user enters data and
then uses the navigation controls to move on, the record just edited /
added is saved. I want to intercept at this point to ensure that all
the required fields have been entered correctly. Can I do this?

Stapes
 
Put the validation code in the form's BeforeUpdate event procedure. This has
a Cancel argument whose return value can be set to true if the validation
criteria are not satisfied, e.g.

Dim strMessage As String
Dim blnCancel As Boolean

If IsNull(Me.SomeControl) Then
strMessage = "A value must be entered in field X."
blnCancel = True
ElseIf IsNull(Me.SomeOtherControl) Then
strMessage = "A value must be entered in field Y."
blnCancel = True
ElseIf IsNull(Me.YetAnotherControl) Then
strMessage = "A value must be entered in field Z."
blnCancel = True
End If

If blnCancel Then
MsgBox strMessage, vbExclamation, "Warning"
Cancel = True
End If

Ken Sheridan
Stafford, England
 

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