Trevor
03-09-2008, 08:19 PM
I have a string of questions for data validation, each with a custom error message, I would like to stop the processing between questions. you can see by looking at my questions that there is "if vbok then goto endd:"
this only works for 1 question and the the command button will not work any more, but if I remove the "if vbok then goto endd:" then after clicking ok on an error message , the user is then presented with the next error message.
I have tried changeing from if len to just if <arg> = "" and the command button will not respond (I know thats strange becuse I have tons of IF statements throught my DB, here is my code of error messages:
If Len(Me.[To C/O] & vbNullString) = 0 Then MsgBox "To C/O is blank, if there isn't data for To C/O then type 'N/A'", vbInformation, _
"Data Required..."
' If vbOK Then GoTo Endd
If Len(Me.[To Address] & vbNullString) = 0 Then MsgBox "To Address is blank, you must enter an individual's Street address ", vbInformation, _
"Data Required..."
' If vbOK Then GoTo Endd
If Len(Me.[To Address Line 2] & vbNullString) = 0 Then MsgBox "To Address Lin 2 is blank, if there isn't data for To Address Line 2 then type 'N/A'", vbInformation, _
"Data Required..."
' If vbOK Then GoTo Endd
If Len(Me.[To Apt./Rm. #] & vbNullString) = 0 Then MsgBox "To Apt./Rm. # is blank, if there isn't data for To To Apt./Rm. # then type 'N/A'", vbInformation, _
"Data Required..."
' If vbOK Then GoTo Endd
If Len(Me.[To City] & vbNullString) = 0 Then MsgBox "To City is blank, you must enter an individual's City", vbInformation, _
"Data Required..."
' If vbOK Then GoTo Endd
If Len(Me.[To State] & vbNullString) = 0 Then MsgBox "To State is blank, you must enter an individual's State", vbInformation, _
"Data Required..."
' If vbOK Then GoTo Endd
If Len(Me.[To Zip Code] & vbNullString) = 0 Then MsgBox "To Zip Code is blank, you must enter an individual's Zip Code ", vbInformation, _
"Data Required..."
' If vbOK Then GoTo Endd
If Len(Me.[tech] & vbNullString) = 0 Then MsgBox "Mail Entered by is blank, you must select your name from the 'Mail Entered by combo box", _
vbInformation + vbOKOnly, "Data Required..."
' If vbOK Then GoTo Endd
' Endd:
End Sub
this works for producing desired error messages:
If Len(Me.[Report created by] & vbNullString) = 0 Then
MsgBox "This requires a VMSU technician's name selected from the " & vbNewLine & _
"'Report Created By' combo box", vbInformation + vbOKOnly, "Data Required"
If vbOK Then GoTo Endd
If Len(Me.[Cluster] & vbNullString) = 0 Then
MsgBox "This requires a Cluster selected from the " & vbNewLine & _
"'Cluster' combo box", vbInformation + vbOKOnly, "Data Required"
If vbOK Then GoTo Endd
If Len(Me.[State] & vbNullString) = 0 Then
MsgBox "This requires a State selected from the " & vbNewLine & _
"'State' combo box", vbInformation + vbOKOnly, "Data Required"
If Len(Me.[subject] & vbNullString) = 0 Then
MsgBox "Subject can not be blank this is the subject line of the e-mail", _
vbInformation + vbOKOnly, "Data Required"
If Len(Me.[msgBody] & vbNullString) = 0 Then
MsgBox "Message can not be blank, if you do not want a message to precede your report, then type 'N/A'", _
vbInformation + vbOKOnly, "Data Required"
is there a command already in vba that I could call that would simple stop processing and when the command button is clicked again the process will start from the beginning?
this only works for 1 question and the the command button will not work any more, but if I remove the "if vbok then goto endd:" then after clicking ok on an error message , the user is then presented with the next error message.
I have tried changeing from if len to just if <arg> = "" and the command button will not respond (I know thats strange becuse I have tons of IF statements throught my DB, here is my code of error messages:
If Len(Me.[To C/O] & vbNullString) = 0 Then MsgBox "To C/O is blank, if there isn't data for To C/O then type 'N/A'", vbInformation, _
"Data Required..."
' If vbOK Then GoTo Endd
If Len(Me.[To Address] & vbNullString) = 0 Then MsgBox "To Address is blank, you must enter an individual's Street address ", vbInformation, _
"Data Required..."
' If vbOK Then GoTo Endd
If Len(Me.[To Address Line 2] & vbNullString) = 0 Then MsgBox "To Address Lin 2 is blank, if there isn't data for To Address Line 2 then type 'N/A'", vbInformation, _
"Data Required..."
' If vbOK Then GoTo Endd
If Len(Me.[To Apt./Rm. #] & vbNullString) = 0 Then MsgBox "To Apt./Rm. # is blank, if there isn't data for To To Apt./Rm. # then type 'N/A'", vbInformation, _
"Data Required..."
' If vbOK Then GoTo Endd
If Len(Me.[To City] & vbNullString) = 0 Then MsgBox "To City is blank, you must enter an individual's City", vbInformation, _
"Data Required..."
' If vbOK Then GoTo Endd
If Len(Me.[To State] & vbNullString) = 0 Then MsgBox "To State is blank, you must enter an individual's State", vbInformation, _
"Data Required..."
' If vbOK Then GoTo Endd
If Len(Me.[To Zip Code] & vbNullString) = 0 Then MsgBox "To Zip Code is blank, you must enter an individual's Zip Code ", vbInformation, _
"Data Required..."
' If vbOK Then GoTo Endd
If Len(Me.[tech] & vbNullString) = 0 Then MsgBox "Mail Entered by is blank, you must select your name from the 'Mail Entered by combo box", _
vbInformation + vbOKOnly, "Data Required..."
' If vbOK Then GoTo Endd
' Endd:
End Sub
this works for producing desired error messages:
If Len(Me.[Report created by] & vbNullString) = 0 Then
MsgBox "This requires a VMSU technician's name selected from the " & vbNewLine & _
"'Report Created By' combo box", vbInformation + vbOKOnly, "Data Required"
If vbOK Then GoTo Endd
If Len(Me.[Cluster] & vbNullString) = 0 Then
MsgBox "This requires a Cluster selected from the " & vbNewLine & _
"'Cluster' combo box", vbInformation + vbOKOnly, "Data Required"
If vbOK Then GoTo Endd
If Len(Me.[State] & vbNullString) = 0 Then
MsgBox "This requires a State selected from the " & vbNewLine & _
"'State' combo box", vbInformation + vbOKOnly, "Data Required"
If Len(Me.[subject] & vbNullString) = 0 Then
MsgBox "Subject can not be blank this is the subject line of the e-mail", _
vbInformation + vbOKOnly, "Data Required"
If Len(Me.[msgBody] & vbNullString) = 0 Then
MsgBox "Message can not be blank, if you do not want a message to precede your report, then type 'N/A'", _
vbInformation + vbOKOnly, "Data Required"
is there a command already in vba that I could call that would simple stop processing and when the command button is clicked again the process will start from the beginning?