Passing a variable to a GoTo

P

Planner

I am trying to pass a public variable between modules to a Goto
statement.

Example
Public Sub Do_a_Lot (Err_Code)
Dim Err_Code As Integer

'When something goes wrong

On Error Resume Next
Err_Code = 1

Call Errorcall(Err_Code)
End Sub

The in a seperate Module I have the Error handling

Public Sub Errorcall(Err_Code)
X=Err_Code
Goto X:

However the macro errors out when trying to initialise the Errorcall
module because whilst compiling it hits the Goto statement with label
X not defined, but it needs to be defined by the Err_code.

Thanks in advance

John
 
P

Peter T

Select Case Err_Code

Not sure your use of Goto is the best approach though.

Regards,
Peter T
 

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

Top