Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cannot catch the error

Status
Not open for further replies.

davikokar

Technical User
May 13, 2004
523
IT
Hallo I have a code that ignores the "On Error Go To". This is the situation:

Code:
Private Sub deleteTables()
    Set m_db = CurrentDb
    Dim i As Integer
    For i = 0 To UBound(m_tableName)
On Error GoTo Err_DeleteTable
        m_db.TableDefs.Delete m_tableName(i)
Err_DeleteTable:
    Next
End Sub

if the table is not present in the database, it will raise the error "Item not found in the collection". I would expect the function to continue because I declare that On Error it should just try the next value. But this does't happen: this function will cause a crash.

Any idea?

Thanks
 
Replace this:
On Error GoTo Err_DeleteTable
with this:
On Error Resume Next

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
your on error statement needs to go at the top of your code not at the bottom.

Private Sub deleteTables()
On Error GoTo errLable
declare variables
code
exit sub
errlable:
error trapping
resume instructions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top