RunTime Error 2465

ECEstudent

Registered User.
Local time
Today, 00:49
Joined
Jun 12, 2013
Messages
153
Does anyone know what is wrong with this line of code:

If Err.Number = 3146 Then 'For an odbc timeout

SendKeys ["{F5}", True] 'pressing F5 so the code would go on

End If

I keep getting this error:

Run-time error 2465, Microsoft Access can't find field 'l1' referred to in your expression.
 
Suggest instead you use in your error handling code

Code:
SELECT CASE Err.Number
    Case 3146
        Resume Next
    Case Else
        ...error handling code
End Select

But if you want to stick with sendkeys then it should be

SendKeys ("{F5}", True)
 
Resume next jumps to the next line after the line of code it got stuck on. What is basically happening (to result in error 3146) is just a connection fail because the ODBC runtime is low or the server is busy. I still want that line of code to COMPLETE what it's doing but according to what i'm doing, if I do 'resume'...it pretty much goes in an endless loop and if I do 'resume next' it jumps to the line of code AFTER the line that I need to complete. Any help appreciated!!
 
Not sure how your code is written, I am just writing some pseudo code.
Code:
Private Sub connectToDB()
On Error GoTo errRoutine
   [COLOR=Green] 'your connectivity CODE[/COLOR]
    
exitOnErr:
    Exit Sub
errRoutine:
    Select Case Err.Number
        Case 3146
            SendKeys ("{F5}", True)
            [COLOR=Blue]Pause (3)[/COLOR]
            Resume
        Case Else
            [COLOR=Green]'...error handling code[/COLOR]
    End Select
End Sub
Where Pause is a user defined function (needs to go in a common module) that allows the CODE to wait..
Code:
Public Function [COLOR=Blue]Pause[/COLOR](NumberOfSeconds As Variant)
[COLOR=Green]'**********************
'Code Courtesy of
'    ghudson (AWF)
'**********************[/COLOR]
On Error GoTo Err_Pause
    Dim PauseTime As Variant, start As Variant
    PauseTime = NumberOfSeconds
    start = Timer
    Do While Timer < start + PauseTime
        DoEvents
    Loop
Exit_Pause:
    Exit Function
Err_Pause:
    MsgBox Err.Number & " - " & Err.Description, vbCritical, "Pause()"
    Resume Exit_Pause
End Function
 

Users who are viewing this thread

Back
Top Bottom