Access: Blank Field Prevention

A common Access database problem is incomplete records. Not only can incomplete records lead to failed applications—such as mailing labels with no addresses on them—but they can also lead to duplication of records when users re-enter a record because the previously entered one was incomplete...

Example, let’s say you've created a form for a table that lists the contact information of your customers. Since you carry on most of your business over the phone, it is necessary that each record contains both a work number and a cell phone number. To prevent users from entering records without this data, follow these steps:

1.    Open the form in Design view.
2.    Click the Properties button in the Form toolbar.
3.    Click the Event tab.
4.    Click in the BeforeUpdate property box and select [Event Procedure] from the drop-down list.
5.    Click the Build button.
6.    Enter the following code at the prompt:
      'If the Contact Phone Number or Mobile Phone is left blank, display a
       message and cancel the update.

       If IsNull(Me.WorkPhone) Or
       IsNull(Me.MobilePhone) Then
       MsgBox "The Contact Work Phone" & vbCrLf & _
       "And Contact Mobile Phone Must All be Entered.", _
       vbCritical, _
       "Canceling Update"
       Me.FirstName.SetFocus
       Cancel = True
       End If
7.    Press [Alt]Q.

Now, if a user attempts to move to the next record without entering these phone numbers, the system will display a message and prevent updates until the appropriate fields are completed.