I
Ian on Cowan
Can anyone help with this one? I have a subroutine, shown below. It should
delete the linkes to tables in a back end Access DB, leaving one table (not
linked) "version" in the front end Access program. It does this BUT will not
delete any tables with names beginning with O or further above in the
alphabet. It behaves the same way without the If... then clause, and the same
way if I run it stand alone in a module.
I am completely puzzled by this bizarre behaviour; any ideas?
Private Sub Form_Close()
Dim db As Database
Set db = CurrentDb()
Dim Tbl As DAO.TableDef
On Error GoTo HandleErr
For Each Tbl In CurrentDb.TableDefs
With Tbl
If Tbl.Name <> "version" Then
CurrentDb.Execute "Drop Table [" & Tbl.Name & "]"
End If
End With
Next Tbl
ExitHere:
Set Tbl = Nothing
Exit Sub
HandleErr:
MsgBox Err & ":Err.Description", , "Err in Deleting Links & [" &
Tbl.Name & "]"
Resume ExitHere
Resume
End Sub
delete the linkes to tables in a back end Access DB, leaving one table (not
linked) "version" in the front end Access program. It does this BUT will not
delete any tables with names beginning with O or further above in the
alphabet. It behaves the same way without the If... then clause, and the same
way if I run it stand alone in a module.
I am completely puzzled by this bizarre behaviour; any ideas?
Private Sub Form_Close()
Dim db As Database
Set db = CurrentDb()
Dim Tbl As DAO.TableDef
On Error GoTo HandleErr
For Each Tbl In CurrentDb.TableDefs
With Tbl
If Tbl.Name <> "version" Then
CurrentDb.Execute "Drop Table [" & Tbl.Name & "]"
End If
End With
Next Tbl
ExitHere:
Set Tbl = Nothing
Exit Sub
HandleErr:
MsgBox Err & ":Err.Description", , "Err in Deleting Links & [" &
Tbl.Name & "]"
Resume ExitHere
Resume
End Sub