On Error of an On Error

  • Thread starter Thread starter none
  • Start date Start date
N

none

How do I write an On Error of an On Error? For example, if an error
occurs when trying to open a linked table, I would like to open up the
linked table manager for the user to link the tables properly.
However, if that is not installed, I would like to give the user a
error message that I will write. At the moment, my code which errs
out is as follows:

========================
Private Sub Form_Current()

' Checks to see if all table is there
On Error GoTo TableMgr

If (DCount("*", "qReport") > 0) Then
MsgBox "This should not be 0.", vbOKOnly, "Not 0"

End If

Exit Sub

TableMgr:
MsgBox "The Linked Table Manager will open.", vbOKOnly, "Table
Manager"
Application.Run ("acwztool.att_Entry")
On Error Resume Next 'GoTo NeedToInstallLinkedTableManager

NeedToInstallLinkedTableManager:
MsgBox "The Linked Table Manager needs to be installed.",
vbOKOnly, "The Linked Table Manager add-on needs to be installed."

End Sub

========================

Thank You!
 
You can nest On Error without any problems. The problem with your code is
that you have the 'On Error Resume Next' *after* you issue the Application.
Run.

The code should be:

On Error Goto NoTableManager
Application.Run
On Error Goto 0 'Clears the error and revert to the earlier error handling's
behavior

Exit Sub

NoTableManager:

Your Message box here

End Sub
 
Thank you for your reply. Unfortunately, I had a error in the code
that I was trying to run. So, basically, if it errs out because the
tables are not linked, it calls up the linked tables manager; if it
errs out because the linked tables manager is not installed, it gives
another message.

The code should have read:

========================
Private Sub Form_Current()

' Checks to see if all table is there
On Error GoTo TableMgr

If (DCount("*", "qReport") > 0) Then
MsgBox "This should not be 0.", vbOKOnly, "Not 0"

End If

Exit Sub

TableMgr:
MsgBox "The Linked Table Manager will open.", vbOKOnly, "Table
Manager"
Application.Run ("acwztool.att_Entry")
On Error GoTo NeedToInstallLinkedTableManager

NeedToInstallLinkedTableManager:
MsgBox "The Linked Table Manager needs to be installed.",
vbOKOnly, "The Linked Table Manager add-on needs to be installed."

End Sub

========================

However, this is not producing the behavior I was hoping for. It
gives me a debug error if it can't find the linked tables manager.
Thank you!
 
Thank you for the references, I will look them up. However, just for
my edification, if I should run into needing to have an error
statement from an error statement in the future, what is the syntax?
What signals the end of the first error statement so that I can have a
second error statement, without it giving me a debug error?

Thank you!
 
TableMgr:
MsgBox "The Linked Table Manager will open.", vbOKOnly, "Table
Manager"
On Error Resume Next
Application.Run ("acwztool.att_Entry")
If Err.Number <> 0 Then
MsgBox "The Linked Table Manager needs to be installed.",
vbOKOnly, "The Linked Table Manager add-on needs to be installed."
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top