L
Lance F via AccessMonster.com
The problem is that when the user types the wrong/invalid data in the drop-
down field, but doesn't hit enter or the tab key, then uses the mouse to
click the submit button. The code will send the email, but not save the
record to the database because of the error.
I'm trying to call out the error at the time that the user clicks the submit
button with a message that "you have invalid data, your issue will not be
logged".
What is wrong with my code below:
Public Function SubmitDE()
Dim frmActive As Form
Set frmActive = Screen.ActiveForm
On Error GoTo Err_SubmitDE
'If frmActive.Dirty = True Then Exit Function
If (IsNull(frmActive.JobOrder)) Then
' If no Job Order selected, stop procedure
MsgBox "You Must Enter A Valid Job Order#"
Exit Function
Else
If (IsNull(frmActive.MAIdentifier)) Then
' If no MA Identifier selected, stop procedure
MsgBox "You Must Enter A MA Identifier Number"
Exit Function
Else
If (IsNull(frmActive.CompanyName)) Then
' If no Company Name selected, stop procedure
MsgBox "You Must Enter A Company Name"
Else
If (IsNull(frmActive.Reportedby)) Then
' If no Company Name selected, stop procedure
MsgBox "You Must Enter A Reported By Name"
Else
If (IsNull(frmActive.AssignedTo)) Then
' If no Company Name selected, stop procedure
MsgBox "You Must Enter An Assigned To Name"
Else
Cancel = True
'If all fields are completed, then ok to send email
frmActive.Refresh
DoCmd.SendObject acSendNoObject, , , frmActive.AssignedTo.Column,,,,,,False
'The code above automatically sends the email thru outlook with option to
send "yes" or "no"
'here i'm trying to capture which button the user clicked
If vbNo Then
MsgBox "This Record Will Be Save."
DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNewRec
Else
If vbYes Then
MsgBox "You Chose Not To Send This Email. This Issue Will Not Be
Save."
End If
End If
End If
End If
End If
End If
End If
Exit_SubmitDE:
Exit Function
Err_SubmitDE:
'here i'm trying to catch the error if the user types invalid data and
clicks the submit button without exiting the field with the invalid data
If vbYes Then
MsgBox "You Chose Not To Send This Email, Or Have An Error. This Issue
Will Not Be Save."
On Error Resume Next
MsgBox "You Have Invalid data on your form. This issue cannot be logged!
Please check Your Form."
End If
Exit Function
Resume Exit_SubmitDE
End Function
down field, but doesn't hit enter or the tab key, then uses the mouse to
click the submit button. The code will send the email, but not save the
record to the database because of the error.
I'm trying to call out the error at the time that the user clicks the submit
button with a message that "you have invalid data, your issue will not be
logged".
What is wrong with my code below:
Public Function SubmitDE()
Dim frmActive As Form
Set frmActive = Screen.ActiveForm
On Error GoTo Err_SubmitDE
'If frmActive.Dirty = True Then Exit Function
If (IsNull(frmActive.JobOrder)) Then
' If no Job Order selected, stop procedure
MsgBox "You Must Enter A Valid Job Order#"
Exit Function
Else
If (IsNull(frmActive.MAIdentifier)) Then
' If no MA Identifier selected, stop procedure
MsgBox "You Must Enter A MA Identifier Number"
Exit Function
Else
If (IsNull(frmActive.CompanyName)) Then
' If no Company Name selected, stop procedure
MsgBox "You Must Enter A Company Name"
Else
If (IsNull(frmActive.Reportedby)) Then
' If no Company Name selected, stop procedure
MsgBox "You Must Enter A Reported By Name"
Else
If (IsNull(frmActive.AssignedTo)) Then
' If no Company Name selected, stop procedure
MsgBox "You Must Enter An Assigned To Name"
Else
Cancel = True
'If all fields are completed, then ok to send email
frmActive.Refresh
DoCmd.SendObject acSendNoObject, , , frmActive.AssignedTo.Column,,,,,,False
'The code above automatically sends the email thru outlook with option to
send "yes" or "no"
'here i'm trying to capture which button the user clicked
If vbNo Then
MsgBox "This Record Will Be Save."
DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNewRec
Else
If vbYes Then
MsgBox "You Chose Not To Send This Email. This Issue Will Not Be
Save."
End If
End If
End If
End If
End If
End If
End If
Exit_SubmitDE:
Exit Function
Err_SubmitDE:
'here i'm trying to catch the error if the user types invalid data and
clicks the submit button without exiting the field with the invalid data
If vbYes Then
MsgBox "You Chose Not To Send This Email, Or Have An Error. This Issue
Will Not Be Save."
On Error Resume Next
MsgBox "You Have Invalid data on your form. This issue cannot be logged!
Please check Your Form."
End If
Exit Function
Resume Exit_SubmitDE
End Function