Automatically resume code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have developed an Access application that communicates with a billing
system and allows users to easily send data to the billing system.
Occasionally, Access losses contact with the billing system and I get an
error message; in order to re-establish the connection I select debug and
press the green run sub/userform button. This works, it re-establishes the
connection and Access continues my problem is that the user who use the
application don't have access to the code and never even see the error
message. When Access losses contact with the billing system I need the users
to see a message box that resumes the code when a resume button is selected.
How can I do this?

Thanks Alex
 
Instead of trying to automate the resuming of the code, is it possible to
check if the connection is active? It sounds like it is timing out. I would
try to write some code before the part that is generating the error, and
re-connecting if necessary (to prevent the error from happening instead of
addressing it).
 
First, you need to determine the Error Number being generated when the
conntection is lost. Then, you need to include an error handler in the
procedure (sub or function) that will check for that error and allow the user
to continue or cancel:

Sub ProcessBilling

On Error Goto ProcessBilliing_Err

ProcessBilling_Retry:

ProcessBilling_Exit:

ProcessBilling_Err:

If Err_Number = 777 (not a real number, just for example) Then
If MsgBox("Connection Lost", vbRetryCancel) = vbRetry Then
Err.Clear
Call ConnectToBilling
Goto ProcessBilling_Retry
End if
Else
MsgBox Err.Number & " " & Err.Description
End If

Got ProcessBilling_Exit
End Sub
 
Back
Top