Hi
Not very experienced at this VBA lark so hoping someone out there can enlighten me.
I am trying to put a simple error trap into a procedure in Access VBA.
Here is the code:
Sub Tbay()
On Error GoTo Proc_Err
'update linked tables to latest Torbay month mdb file
'if correct database not found, abort run
PCT = "TORBAY CARE TRUST"
LinkTorbay ' this is another sub that I pass the global PCT variable to
If LinkCheck = False Then
Exit Sub
End If
DoCmd.SetWarnings False
'I've removed the code that does everything in this bit
PCT = ""
MsgBox "Processing completed", vbOKOnly
Proc_Error:
DoCmd.SetWarnings True
MsgBox "An error occurred. Please check and re-start processing", vbOKOnly
Exit Sub
End Sub
The actual code is a lot longer but I've cut it down to simplify and
illustrate the problem. The longer version works without the error trapping
statement but won't compile - with the same error as this shortened version.
My problem is with the 'On Error Goto Proc_Error' line as I get a
compile error (label not defined). What am i doing wrong?
Not very experienced at this VBA lark so hoping someone out there can enlighten me.
I am trying to put a simple error trap into a procedure in Access VBA.
Here is the code:
Sub Tbay()
On Error GoTo Proc_Err
'update linked tables to latest Torbay month mdb file
'if correct database not found, abort run
PCT = "TORBAY CARE TRUST"
LinkTorbay ' this is another sub that I pass the global PCT variable to
If LinkCheck = False Then
Exit Sub
End If
DoCmd.SetWarnings False
'I've removed the code that does everything in this bit
PCT = ""
MsgBox "Processing completed", vbOKOnly
Proc_Error:
DoCmd.SetWarnings True
MsgBox "An error occurred. Please check and re-start processing", vbOKOnly
Exit Sub
End Sub
The actual code is a lot longer but I've cut it down to simplify and
illustrate the problem. The longer version works without the error trapping
statement but won't compile - with the same error as this shortened version.
My problem is with the 'On Error Goto Proc_Error' line as I get a
compile error (label not defined). What am i doing wrong?