matt beamish
Registered User.
- Local time
- Today, 12:57
- Joined
- Sep 21, 2000
- Messages
- 208
I have put this code together to delete linked tables if they exist, so that tables from a different back-end can be linked in, as required. I know my understanding of error handling is poor. Would anyone please have a look at what i have written and comment on where I need to improve? If the table does not exist, I want the procedure to continue.
thanks in advance
thanks in advance
Code:
Private Sub Command1_Click()
Dim strT_Samplelistsite
Dim strT_Contexts
Dim strT_Cuts
Dim str_T_Subgroup
On Error Resume Next
strT_Samplelistsite = CurrentDb.TableDefs(T_Samplelistsite)
If TableExists = True Then
DoCmd.DeleteObject acTable, "T_Samplelistsite"
Else: TableExists = False
End If
strT_Contexts = CurrentDb.TableDefs(T_Contexts)
If TableExists = True Then
DoCmd.DeleteObject acTable, "T_Contexts"
Else: TableExists = False
End If
strT_Cuts = CurrentDb.TableDefs(T_Cuts)
If TableExists = True Then
DoCmd.DeleteObject acTable, "T_Cuts"
Else: TableExists = False
End If
strT_Subgroup = CurrentDb.TableDefs(T_Subgroup)
If TableExists = True Then
DoCmd.DeleteObject acTable, "T_Subgroup"
Else: TableExists = False
End If
If Me.Dirty Then Me.Dirty = False
DoCmd.Close
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
ErrorCode:
MsgBox Err.Description
End Sub