Hey all, i've got an odd problem with a query i'm trying to call from code.
The query itself is nothing exotic, just a regular selection query with a few filters on it.
When i run the query from the gui i get the correct results, 11 records, but when i call it from code it only returns 1 record. It returns the first record from the correct resultset but doesn't return the other 10.
I have no idea why it's doing this, i've used code like this plenty of times and never had problems before.
I tried it like this:
Public Function test()
Dim db As Database
Dim rs_rsz As DAO.Recordset
Dim i As Integer
Set db = CurrentDb()
Set rs_rsz = db.OpenRecordset("myquery")
rs_rsz.MoveFirst
For i = 0 To rs_rsz.RecordCount - 1
<dostuff>
Next
End Function
And like this:
Public Function test()
Dim db As Database
Dim rs_rsz As DAO.Recordset
Dim qdf As QueryDef
Dim i As Integer
Set db = CurrentDb()
Set qdf = db.QueryDefs("myquery")
Set rs_rsz = qdf.OpenRecordset()
rs_rsz.MoveFirst
For i = 0 To rs_rsz.RecordCount - 1
<dostuff>
Next
End Function
The query itself is nothing exotic, just a regular selection query with a few filters on it.
When i run the query from the gui i get the correct results, 11 records, but when i call it from code it only returns 1 record. It returns the first record from the correct resultset but doesn't return the other 10.
I have no idea why it's doing this, i've used code like this plenty of times and never had problems before.

I tried it like this:
Public Function test()
Dim db As Database
Dim rs_rsz As DAO.Recordset
Dim i As Integer
Set db = CurrentDb()
Set rs_rsz = db.OpenRecordset("myquery")
rs_rsz.MoveFirst
For i = 0 To rs_rsz.RecordCount - 1
<dostuff>
Next
End Function
And like this:
Public Function test()
Dim db As Database
Dim rs_rsz As DAO.Recordset
Dim qdf As QueryDef
Dim i As Integer
Set db = CurrentDb()
Set qdf = db.QueryDefs("myquery")
Set rs_rsz = qdf.OpenRecordset()
rs_rsz.MoveFirst
For i = 0 To rs_rsz.RecordCount - 1
<dostuff>
Next
End Function