I have a sub to run an append query. If the append query has no records, the code breaks.
How do I exit the sub on error?
Thank you!
How do I exit the sub on error?
Thank you!
Code:
Option Compare Database
Private Sub cmdAppendImportContacts_Click()
Msg = " Are you sure you want to append imported data into Contacts table? Click Yes to Append; Click No to Delete imported table; Click Cancel to Cancel operation"
Response = MsgBox(Msg, vbYesNoCancel)
If Response = vbYes Then
'<=== runactivemacro clean()
'[URL unfurl="true"]https://msdn.microsoft.com/en-us/library/5hsw66as.aspx[/URL]
DoCmd.RunMacro "mcrAppendImportContacts"
Exit Sub
End If
If Response = vbNo Then
DoCmd.DeleteObject acTable, "ImportContacts_xlsx"
MsgBox " ImportContacts Table has been deleted. To Append, re-import ImportContacts.xlsx "
Exit Sub
End If
If Response = vbCancel Then
MsgBox "Action Cancelled"
Exit Sub
End If
End Sub