chuckcoleman
Registered User.
- Local time
- Today, 10:36
- Joined
- Aug 20, 2010
- Messages
- 377
Hi, I have in the Unload property of a form the code shown. The code checks if there is an order without a Requested Due Date. If the Requested Due Date is blank it presents a vbMsgBox with OK or Cancel and the message shown. It all works perfectly, almost. If the person clicks on OK, it runs a query to remove that record and lets the form close. If the user clicks on Cancel it cancel's closing the and allows the user to enter the Requested Due Date. However, it also display an error, "No Current Record". And, I don't believe it's coming from the error handler because I prefaced the Msg with the number 19 just so I could be sure.
The question is how do I eliminate the popup error, No Current Record? Basically, I've just canceled closing the form and I don't understand why it thinks there isn't a current record. It's there, I can see it.
The question is how do I eliminate the popup error, No Current Record? Basically, I've just canceled closing the form and I don't understand why it thinks there isn't a current record. It's there, I can see it.
Code:
Dim Response As VbMsgBoxResult
If DCount("*", "Count Blank Work Orders for a Client-Count with Reason") > 0 Then
Response = MsgBox("You have not specified a Requested Due Date. If you click on Cancel, you will then be able " _
& "to cancel closing this form and add a Requested Due Date. If you click on OK, the form will close and " _
& "this Work Order will be deleted.", vbQuestion + vbDefaultButton2 + vbOKCancel)
If Response = vbCancel Then
Cancel = True
Exit Sub
Else
If Response = vbOK Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "Delete Blank Work Orders for a Client"
DoCmd.Close acQuery, "Delete Blank Work Orders for a Client"
DoCmd.SetWarnings True
End If
End If
End If
Form_Unload_Exit:
Exit Sub
Form_Unload_Error:
If Err.Number = 3021 Then
MsgBox "19-No current Record"
Else
MsgBox Err.Description
Resume Form_Unload_Exit
End If