RunTime Error 2465 (1 Viewer)

ECEstudent

Registered User.
Local time
Today, 07:15
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.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 15:15
Joined
Feb 19, 2013
Messages
16,685
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)
 

ECEstudent

Registered User.
Local time
Today, 07:15
Joined
Jun 12, 2013
Messages
153
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!!
 

pr2-eugin

Super Moderator
Local time
Today, 15:15
Joined
Nov 30, 2011
Messages
8,494
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

Top Bottom