I have a button with code. I want to close the record if there isn't any data. If there is data I want to delete the record. Is there a more efficient way than what I have below? I don't like the first If statement.
On Error GoTo Error_Handler
If IsNull([Grade]) And IsNull([FName]) And IsNull([LName]) Then
DoCmd.Close
DoCmd.OpenForm "frmMainPageCustomers", acNormal, "", "", , acNormal
DoCmd.SetWarnings (True)
Else
DoCmd.SetWarnings (False)
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.Close
DoCmd.OpenForm "frmMainPageCustomers", acNormal, "", "", , acNormal
DoCmd.SetWarnings (True)
End If
Error_Handler_Exit:
On Error Resume Next
Exit Sub
Error_Handler:
MsgBox Err.Description
Resume Error_Handler_Exit
On Error GoTo Error_Handler
If IsNull([Grade]) And IsNull([FName]) And IsNull([LName]) Then
DoCmd.Close
DoCmd.OpenForm "frmMainPageCustomers", acNormal, "", "", , acNormal
DoCmd.SetWarnings (True)
Else
DoCmd.SetWarnings (False)
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.Close
DoCmd.OpenForm "frmMainPageCustomers", acNormal, "", "", , acNormal
DoCmd.SetWarnings (True)
End If
Error_Handler_Exit:
On Error Resume Next
Exit Sub
Error_Handler:
MsgBox Err.Description
Resume Error_Handler_Exit