Deleting tables in Access Database, if they exist
How can this be done? I have written code to add tables from one database to another but then it will give me an error if the table already exits. Therefore I want to delete the table in the target database if it exists and replace it with the copied table from the source database.
here is the original code:
Public Sub DB_CopyTable(ByVal DBPathName$, ByVal TargetTable$, ByVal NewTableName$)
On Error GoTo DB_CopyTable_ErrorHandler:
If TargetTable = "TEDSSEQFN" Or TargetTable = "TEDSSEDK_" Then
cnxModelDB.Execute "SELECT " & TargetTable & ".* INTO " & TargetTable & " IN '" & DBPathName & "' From " & NewTableName
Else
cnxMacroLibrary.Execute "SELECT " & TargetTable & ".* INTO " & TargetTable & " IN '" & DBPathName & "' From " & NewTableName
End If
Exit Sub
DB_CopyTable_ErrorHandler:
MsgBox "Error: " & Err.Description, vbCritical + vbOKOnly, "Error " & Err.Number & " in DB_CopyTable_errorhandler"
End Sub
Thanks in advance for your help.
Rgrds,
Maria
|