I have a form I need to validate with the code below. While this may work it would be a lot easier on the user to be presented with a list of incomplete fields at time of either Cancel or Save rather than potentially having to answer multiple warning boxes in succession (I know that would certainly annoy me).
I would like to have a list presented similar to the ones you see on the net telling you what you didn't fill out. Im not sure if this is even possible especially with my lack of Access VBA coding experience but thought I would post anyway to see if anyone could assist me.
I would like to have a list presented similar to the ones you see on the net telling you what you didn't fill out. Im not sure if this is even possible especially with my lack of Access VBA coding experience but thought I would post anyway to see if anyone could assist me.
Code:
Private Sub chkCompleted_BeforeUpdate(Cancel As Integer)
If chkCompleted = False Then
lblDateCompleted.Visible = False
lblDateCompleted.Visible = False
else
lblDateCompleted.Visible = False
lblDateCompleted.Visible = False
End If
If ((IsNull(Me.QueryPhone) Or Me.QueryPhone = "")) Then
MsgBox "You must enter a Contact telephone number", vbInformation, "Data Validation"
Me.QueryPhone.SetFocus
Cancel = True
ElseIf
((IsNull(Me.DateEntered) Or Me.DateEntered = "")) Then
MsgBox "You must enter today's date",
vbInformation, "Data Validation"
Me.DateEntered.SetFocus
Cancel = True
ElseIf
((IsNull(Me.PSUDept) Or Me.PSUDept = "")) Then
MsgBox "You must enter a department",
vbInformation, "Data Validation"
Me.PSUDept.SetFocus
Cancel = True
ElseIf
((IsNull(Me.FormCompBy) Or Me.FormCompBy = "")) Then
MsgBox "You must enter your name",
vbInformation, "Data Validation"
Me.FormCompBy.SetFocus
Cancel = True
ElseIf
((IsNull(Me.ProjTitle) Or Me.ProjTitle = "")) Then
MsgBox "You must enter a Project Title",
vbInformation, "Data Validation"
Me.ProjTitle.SetFocus
Cancel = True
ElseIf
((IsNull(Me.ProjDesc) Or Me.ProjDesc = "")) Then
MsgBox "You must enter a description",
vbInformation, "Data Validation"
Me.ProjDesc.SetFocus
Cancel = True
ElseIf
((IsNull(Me.StartDate) Or Me.StartDate = "")) Then
MsgBox "You must enter a Start Date",
vbInformation, "Data Validation"
Me.StartDate.SetFocus
Cancel = True
ElseIf
((IsNull(Me.ProjectedEndDate) Or Me.ProjectedEndDate = "")) Then
MsgBox "You must enter a Projected End Date",
vbInformation, "Data Validation"
Me.ProjectedEndDate.SetFocus
Cancel = True
ElseIf
((IsNull(Me.Hours) Or Me.Hours = "")) Then
MsgBox "You must enter hours",
vbInformation, "Data Validation"
Me.Hours.SetFocus
Cancel = True
ElseIf
((IsNull(Me.LevelOfEffort) Or Me.LevelOfEffort = "")) Then
MsgBox "You must enter LevelOfEffort",
vbInformation, "Data Validation"
Me.LevelOfEffort.SetFocus
Cancel = True
ElseIf
((IsNull(Me.OtherDivisionalGoal) Or Me.OtherDivisionalGoal = "")) Then
MsgBox "You must enter a Other Divisional Goal",
vbInformation, "Data Validation"
Me.OtherDivisionalGoal.SetFocus
Cancel = True
ElseIf
((IsNull(Me.ProjectSponsor) Or Me.ProjectSponsor = "")) Then
MsgBox "You must enter a Project Sponsor",
vbInformation, "Data Validation"
Me.ProjectSponsor.SetFocus
Cancel = True
ElseIf
((IsNull(Me.SponsoringDepartment) Or Me.SponsoringDepartment = "")) Then
MsgBox "You must enter a Sponsoring Department",
vbInformation, "Data Validation"
Me.SponsoringDepartment.SetFocus
Cancel = True
ElseIf
((IsNull(Me.Collaborators) Or Me.Collaborators = "")) Then
MsgBox "You must enter Collaborators",
vbInformation, "Data Validation"
Me.Collaborators.SetFocus
Cancel = True
ElseIf
((IsNull(Me.PrimaryClient) Or Me.PrimaryClient = "")) Then
MsgBox "You must enter a Primary Client",
vbInformation, "Data Validation"
Me.PrimaryClient.SetFocus
Cancel = True
ElseIf
((IsNull(Me.PrimaryClientDept) Or Me.PrimaryClientDept = "")) Then
MsgBox "You must enter a Primary Client Department",
vbInformation, "Data Validation"
Me.PrimaryClientDept.SetFocus
Cancel = True
ElseIf
((IsNull(Me.ProjectType) Or Me.ProjectType = "")) Then
MsgBox "You must enter a Project Type",
vbInformation, "Data Validation"
Me.ProjectType.SetFocus
Cancel = True
ElseIf
((IsNull(Me.DepartmentID) Or Me.DepartmentID = "")) Then
MsgBox "You must enter a Department ID",
vbInformation, "Data Validation"
Me.DepartmentID.SetFocus
Cancel = True
End Sub