After upgrading my access database from 97 to 2003 I'm running into problems with recordsets opened from querydef objects.
Here's an example
Sub testdao()
Dim db As DAO.Database, RecMain As DAO.Recordset, myQuery As DAO.QueryDef
Dim MillSection As String
Set db = CurrentDb()
Set myQuery = db.QueryDefs("bbk_MainQueryByState")
MillSection = "WDUS"
myQuery.Parameters("[Mill Section]") = MillSection
Set RecMain = myQuery.OpenRecordset()
With RecMain
Do While Not .EOF
Debug.Print "FacilityID=" & !FacilityID
.MoveNext
Loop
End With
End Sub
The error I return is Run Time Error 3001 Invalid argument.
In testing the only thing I tried that made any difference was changing the openrecordset options to...
Set RecMain = myQuery.OpenRecordset(dbOpenDynaset, dbOptimistic)
This starts to work but errors with 3254 cannot lock all records. Well I don't realy need all the records locked, in fact I could use a read only recordset if I could figure it out. But I haven't found any documents that show which parameters work with each other and the above trial was they only attempt that almost produced results.
Anyone have any ideas?
Thanks
dl
Here's an example
Sub testdao()
Dim db As DAO.Database, RecMain As DAO.Recordset, myQuery As DAO.QueryDef
Dim MillSection As String
Set db = CurrentDb()
Set myQuery = db.QueryDefs("bbk_MainQueryByState")
MillSection = "WDUS"
myQuery.Parameters("[Mill Section]") = MillSection
Set RecMain = myQuery.OpenRecordset()
With RecMain
Do While Not .EOF
Debug.Print "FacilityID=" & !FacilityID
.MoveNext
Loop
End With
End Sub
The error I return is Run Time Error 3001 Invalid argument.
In testing the only thing I tried that made any difference was changing the openrecordset options to...
Set RecMain = myQuery.OpenRecordset(dbOpenDynaset, dbOptimistic)
This starts to work but errors with 3254 cannot lock all records. Well I don't realy need all the records locked, in fact I could use a read only recordset if I could figure it out. But I haven't found any documents that show which parameters work with each other and the above trial was they only attempt that almost produced results.
Anyone have any ideas?
Thanks
dl