Run time error 91

luzz

Registered User.
Local time
Today, 00:55
Joined
Aug 23, 2017
Messages
346
Dear all, I would appreciate if you can offer me some helps here. I am facing this run time error '91' for quite some time, it will unexpectedly apppear. This error occurs when i attempt to click the next,previous or save button, it only appears when i did not key in the form or stop at one record for some time. How can i fix it?
 

Attachments

  • Error.jpg
    Error.jpg
    13.4 KB · Views: 108
Click on debug and see what line causes the error. If that doesn't resolve it, post the whole sub and which line throws the error.
 
Click on debug and see what line causes the error. If that doesn't resolve it, post the whole sub and which line throws the error.

Dim param As Parameter
Dim i As Integer
With CurrentDb.CreateQueryDef("", strSQL)
For i = 0 To .Parameters.Count - 1
.Parameters(i) = p(i)
Next
If InStr(strSQL, "SELECT") = 1 And InStr(strSQL, "INTO") = 0 Then
' Simple select query and not Create table query
Set fnAnySQL = .OpenRecordset(dbOpenDynaset)
Else
' Action queries
.Execute (dbFailOnError)
End If
End With

End Function

The line that i bold is the error
and this access file is placed in a server which will be concurrently used by multiple users. So i have no idea if these two factors causes this error
 
I think it's because you haven't instanced an object with the CreateQueryDef method

Something like
Code:
set db = currentdb
set qdf = db.CreateQueryDef("",strSQL)
with qdf
    .....
    ....
end with
 
If you passed a query string with no parameter on it, it will fail.
In short, dont use the function on non parametized query string.
 

Users who are viewing this thread

Back
Top Bottom