G
Gwy
Ive looked through the posts and nobody seems to have this problem: I
want to filter a DAO recordset. I understand that you must copy the
recordset after you filter it. I also understand that it would be alot
more simple to put the restrictions in my WHERE clause, however, for
the purpose of my project, this is not possible/efficient.
Here is an idea of my code:
Private Function test()
Dim db As Database
Dim rs As Recordset
Dim rsFilter As Recordset
Dim strSQL As String
Set db = OpenDatabase(CurrentProject.Path & "\" &
CurrentProject.Name, False, False)
strSQL = "SELECT Pop.SubCode, Pop.Region " & _
"FROM Pop" & _
"WHERE (Pop.Region = 1) " & _
"ORDER BY Pop.Size DESC;"
'My SQL is alot more complexe then this... this is just to give you an
idea
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
rs.Filter = "Pop.SubCode = 9999"
Set rsFilter = rs.OpenRecordset() '***** MY ERROR OCCURS AT THIS
LINE
MsgBox rs.RecordCount
rs.Close
rsFilter.Close
db.Close
End Function
The error is the following:
"Run-time error '3061': Too few parameters. Expected 2."
However the parameters that are expected are optional. I tried filling
them in with various values to no avail.
TIA,
Gwy
want to filter a DAO recordset. I understand that you must copy the
recordset after you filter it. I also understand that it would be alot
more simple to put the restrictions in my WHERE clause, however, for
the purpose of my project, this is not possible/efficient.
Here is an idea of my code:
Private Function test()
Dim db As Database
Dim rs As Recordset
Dim rsFilter As Recordset
Dim strSQL As String
Set db = OpenDatabase(CurrentProject.Path & "\" &
CurrentProject.Name, False, False)
strSQL = "SELECT Pop.SubCode, Pop.Region " & _
"FROM Pop" & _
"WHERE (Pop.Region = 1) " & _
"ORDER BY Pop.Size DESC;"
'My SQL is alot more complexe then this... this is just to give you an
idea
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
rs.Filter = "Pop.SubCode = 9999"
Set rsFilter = rs.OpenRecordset() '***** MY ERROR OCCURS AT THIS
LINE
MsgBox rs.RecordCount
rs.Close
rsFilter.Close
db.Close
End Function
The error is the following:
"Run-time error '3061': Too few parameters. Expected 2."
However the parameters that are expected are optional. I tried filling
them in with various values to no avail.
TIA,
Gwy