Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Form - Mandatory Record 1

Status
Not open for further replies.

tresanus

Technical User
Oct 7, 2007
84
US
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
 
If IsNull(LastName) Or LastName = "" Then
MsgBox "LAST NAME Field Must Be Completed"
EXIT SUB
End If
If IsNull(FirstName) Or FirstName = "" Then
MsgBox "FIRST NAME Field Must Be Completed"
EXIT SUB

End If
If IsNull(Rank) Or Rank = "" Then
MsgBox "Selection Must Be Made For USER RANK Dropdown"
EXIT SUB
End If
If IsNull(CalExperience) Or CalExperience = "" Then
MsgBox "Selection Must Be Made For YEARS CALIBRATION EXPERIENCE Dropdown"
EXIT SUB
End If
If IsNull(AccessLevel) Or AccessLevel = "" Then
MsgBox "Selection Must Be Made For USER ACCESS LEVEL Dropdown"
EXIT SUB
End If
If IsNull(TimeDate) Or TimeDate = "" Then
MsgBox "Double Click TIME STAMP Field to Continue"
EXIT SUB
End If
 
pwise i see where you get the "wise" part of your name
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top