Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Form_BeforeUpdate
If DCount("*", "[COLOR="Red"]YourTableNameHere[/COLOR]") >= 5 Then
MsgBox "Table already has 5 records, you cannot add any more records", vbExclamation, "Record Count Exceeded"
DoCmd.CancelEvent
Else
MsgBox "table does not contain 5 records"
End If
Exit_Form_BeforeUpdate:
Exit Sub
Err_Form_BeforeUpdate:
MsgBox Err.Number & " - " & Err.Description, vbCritical, "Form_BeforeUpdate()"
Resume Exit_Form_BeforeUpdate
End Sub