I have recently created an Access form that contains mandatory records. When the record is not populated with data a message box will appear. The problem I am having is after the user clicks on the message box the form will automatically take them to the next page. I want the form to remain on the page that is missing data in one of the fields.
Now I could re-write the message to tell the user to go back and add the necessary data, but I would much rather the user be unable to go on to the next record without this record being finished.
Here is the code I am working with. I appreciate any help!
Private Sub AddNewRecord_Click()
If IsNull(LastName) Or LastName = "" Then
MsgBox "LAST NAME Field Must Be Completed"
End If
If IsNull(FirstName) Or FirstName = "" Then
MsgBox "FIRST NAME Field Must Be Completed"
End If
If IsNull(Rank) Or Rank = "" Then
MsgBox "Selection Must Be Made For USER RANK Dropdown"
End If
If IsNull(CalExperience) Or CalExperience = "" Then
MsgBox "Selection Must Be Made For YEARS CALIBRATION EXPERIENCE Dropdown"
End If
If IsNull(AccessLevel) Or AccessLevel = "" Then
MsgBox "Selection Must Be Made For USER ACCESS LEVEL Dropdown"
End If
If IsNull(TimeDate) Or TimeDate = "" Then
MsgBox "Double Click TIME STAMP Field to Continue"
End If
On Error GoTo Err_AddNewRecord_Click
DoCmd.GoToRecord , , acNewRec
Exit_AddNewRecord_Click:
Exit Sub
Err_AddNewRecord_Click:
MsgBox Err.Description
Resume Exit_AddNewRecord_Click
End Sub
Now I could re-write the message to tell the user to go back and add the necessary data, but I would much rather the user be unable to go on to the next record without this record being finished.
Here is the code I am working with. I appreciate any help!
Private Sub AddNewRecord_Click()
If IsNull(LastName) Or LastName = "" Then
MsgBox "LAST NAME Field Must Be Completed"
End If
If IsNull(FirstName) Or FirstName = "" Then
MsgBox "FIRST NAME Field Must Be Completed"
End If
If IsNull(Rank) Or Rank = "" Then
MsgBox "Selection Must Be Made For USER RANK Dropdown"
End If
If IsNull(CalExperience) Or CalExperience = "" Then
MsgBox "Selection Must Be Made For YEARS CALIBRATION EXPERIENCE Dropdown"
End If
If IsNull(AccessLevel) Or AccessLevel = "" Then
MsgBox "Selection Must Be Made For USER ACCESS LEVEL Dropdown"
End If
If IsNull(TimeDate) Or TimeDate = "" Then
MsgBox "Double Click TIME STAMP Field to Continue"
End If
On Error GoTo Err_AddNewRecord_Click
DoCmd.GoToRecord , , acNewRec
Exit_AddNewRecord_Click:
Exit Sub
Err_AddNewRecord_Click:
MsgBox Err.Description
Resume Exit_AddNewRecord_Click
End Sub