I made a macro code for empty fields that need to be filled in first before going to new record.
Or
You can use a this code below for module:
Option Compare Database
Option Explicit
Public Function CheckForEntries() As Boolean
'On Error GoTo Err_CheckEntries
Dim strMessage As String
Dim ctl As Control
Dim strControl As String
'set all controls to normal white background
Call SetBackColorNormal
'if not a new record check each controls tag property for Req
If Not Screen.ActiveForm.NewRecord Then
For Each ctl In Screen.ActiveForm.Controls
If (ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox) And ctl.Tag = "Req" Then
'only build a message for the first required control without an entry
If Nz(Len(ctl.Value), 0) = 0 And Nz(Len(strMessage), 0) = 0 Then
'this function requires that the label for the control have the same name as the control
'followed by _Label
strMessage = Screen.ActiveForm(ctl.ControlName & "_Label").Caption & " is a required field."
'set the strControl variable to the name of the required control that is not filled in
strControl = ctl.ControlName
End If
End If
Next
'if there is no message, then all required controls have entries
If Nz(Len(strMessage), 0) > 0 Then
MsgBox strMessage, vbOKOnly, "Required field left blank!"
'set the back color of the required control in question to yellow
Screen.ActiveForm(strControl).BackColor = 65535 'Bright Yellow
'and set the focus to the control
Screen.ActiveForm(strControl).SetFocus
'and set the checkforentries to True so that any code in the form can be handled
CheckForEntries = True
Else
'if all required controls have entries set checkforentries to false
CheckForEntries = False
End If
End If
Exit_CheckEntries:
Exit Function
Err_CheckEntries:
MsgBox Err.Description
GoTo Exit_CheckEntries
End Function
Public Sub SetBackColorNormal()
On Error Resume Next
Dim ctl As Control
For Each ctl In Screen.ActiveForm.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
ctl.BackColor = -2147483643 'normal white back color
End If
Next
End Sub
And Place the code below in a form property
Private Sub Form_Current()
Call SetBackColorNormal
End Sub
Set the tag in property to Req
If you want I can attach a sample for you
Michael