Private Sub Form_BeforeUpdate(Cancel As Integer)
Cancel = Not ValidateForm()
End Sub
Private Function ValidateForm() As String
'--------------------------------------------
ValidateForm = False
'--------------------------------------------
Dim ErrorMsg As String
ErrorMsg = ValidateControl(Me.[Sales Alert Date])
ErrorMsg = ErrorMsg & ValidateControl(Me.[Eligibles])
ErrorMsg = ErrorMsg & ValidateControl(Me.[Region])
ErrorMsg = ErrorMsg & ValidateControl(Me.[Case Type])
ErrorMsg = ErrorMsg & ValidateControl(Me.[Industry])
ErrorMsg = ErrorMsg & ValidateControl(Me.[Product])
If ErrorMsg <> "" Then
ErrorMsg = "The following fields " & _
"within Case Profile are incomplete:" & Chr(13) & _
ErrorMsg & _
"Would you like to continue anyway?"
If MsgBox(Msg, vbYesNo) <> vbYes Then
Exit Function
End If
End If
'--------------------------------------------
ErrorMsg = ValidateControl(Me.[Will Prep])
ErrorMsg = ErrorMsg & ValidateControl(Me.[Eligibles])
ErrorMsg = ErrorMsg & ValidateControl(Me.[Underwriting Requirements])
ErrorMsg = ErrorMsg & ValidateControl(Me.[Logo])
ErrorMsg = ErrorMsg & ValidateControl(Me.[Enrollment Materials])
ErrorMsg = ErrorMsg & ValidateControl(Me.[Enrollment Method])
ErrorMsg = ErrorMsg & ValidateControl(Me.[Online Experience])
ErrorMsg = ErrorMsg & ValidateControl(Me.[Enrollment Recordkeeping])
If ErrorMsg <> "" Then
ErrorMsg = "The following fields " & _
"within Strategy Sold are incomplete:" & Chr(13) & _
ErrorMsg & _
"Would you like to continue anyway?"
If MsgBox(Msg, vbYesNo) <> vbYes Then
Exit Function
End If
End If
'--------------------------------------------
ValidateForm = True
'--------------------------------------------
End Function
Private Function ValidateControl(InControl As TextBox) As String
'--------------------------------------------
ValidateControl = ""
If IsNull(InControl) Then
ValidateControl = InControl.Name & Chr(13)
ElseIf InControl = "Don't Know Yet" Then
ValidateControl = InControl.Name & Chr(13)
End If
'--------------------------------------------
End Function
Monish said:
Brendan - Thanks for taking a look at this...I can show you the entire code
which may help you better undertand the issue.
Adding the " " did not work unfortunately...
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim MyMsg As String
MyMsg = "One or more of the following fields within Case Profile are
incomplete:" & Chr(13) & _
"Sales Alert Date " & Chr(13) & _
"Eligibles " & Chr(13) & _
"Region" & Chr(13) & _
"Case Type" & Chr(13) & _
"Industry" & Chr(13) & _
"Product" & Chr(13) & Chr(13) & _
"Would you like to continue anyway?"
Dim Msg As String
Msg = "One or more of the following fields within Strategy Sold are
incomplete:" & Chr(13) & _
"Will Prep" & Chr(13) & _
"Underwriting Requirements" & Chr(13) & _
"Logo" & Chr(13) & _
"Enrollment Materials" & Chr(13) & _
"Enrollment Method" & Chr(13) & _
"Online Experience" & Chr(13) & _
"Enrollment Recordkeeping" & Chr(13) & Chr(13) & _
"Would you like to continue anyway?"
If IsNull(Me.[Sales Alert Date]) Or IsNull(Me.[Eligibles]) Or
IsNull(Me.[Region]) Or IsNull(Me.[Case Type]) Or IsNull(Me.[Industry]) Or
IsNull(Me.[Product]) Then
If MsgBox(MyMsg, vbYesNo) <> vbYes Then
Cancel = True
End If
End If
If (Me.[Will Prep]) = "Don't Know Yet" Or (Me.[Underwriting Requirements]) =
"Don't Know Yet" Or (Me.[Logo]) = "Don't Know Yet" Or (Me.[Enrollment
Materials]) = "Don't Know Yet Or" (Me.[Enrollment Method]) = "Don't Know Yet"
Or (Me.[Online Experience]) = "Don't Know Yet" Or (Me.[Enrollment
Recordkeeping]) = "Don't Know Yet" Then
If MsgBox(Msg, vbYesNo) <> vbYes Then
Cancel = True
End If
End If
End Sub
Again, thanks
M
Brendan Reynolds said:
It's difficult to be sure without knowing whether those controls are bound
or unbound, and if they are bound, the data types of the fields to which
they are bound. That said, given the information available, my best guess is
that you may just need quotes around "Don't Know Yet", something like ....
If (Me.[Will Prep]) = "Don't Know Yet" Or ... etc.
--
Brendan Reynolds
Hi -
I am receiving a syntax error on the following line of code, and am hoping
somebody more knowledgeable than I can help me define the issue:
If (Me.[Will Prep]) = Don't Know Yet Or (Me.[Underwriting Requirements]) =
Don't Know Yet Or (Me.[Logo]) = Don't Know Yet Or (Me.[Enrollment
Materials])
= Don't Know Yet Or (Me.[Enrollment Method]) = Don't Know Yet Or
(Me.[Online
Experience]) = Don't Know Yet Or (Me.[Enrollment Recordkeeping]) = Don't
Know
Yet Then
If Msgbox(Msg ,vbYesNo)<>vbYes then
cancel = true
end if
End If
Thanks to anyone out there...and everyone who has helped me in the past as
well!
M