Validation Rule?

  • I have a form to enter data.

    There is a number field and a Date field I want to make sure the user enters something into. If not, and they try to close the form, I want an error box to pop up and tell them they cannot leave it blank.

    Any ideas how to accomplish this?

  • In the BeforeUpdate event, you check the fields and issue a cancel i it fails your validation

    e.g.

    Private Sub Form_BeforeUpdate(Cancel As Integer)

    IF NZ(Me.txtDate,"") = "" then

    Msgbox "You must enter a date", vbCritical + vbokonly,"Validation Error"

    me.txtDate.Setfocus

    Cancel = True

    End If

    End Sub

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply