I have a query ListSalesAll that is used in a number of places
I want to be able to pass a parameter to this to limit the number of rows returned as once the database gets growing it could be quite large.
I tried doing this
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("ListSalesAll")
qdf!formtype = "A"
qdf!Formsalesperson = pubUserName
qdf.Execute
qdf.Close
Set qdf = Nothing
Set dbs = Nothing
WHich worked on an update query but it doesn't seem to like a "SELECT" query, and besides I wasn't sure how to process each row returned.
I then tried this
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim strSQL As String
Set db = CurrentDb
strSQL = "ListSalesAll"
Set rs = db.OpenRecordset(strSQL)
Do While Not rs.EOF
If rs!TypeMain <> "A" Then
'exit
Else
If rs!CopyRecord Then
'do something here
Else
'exit
End If
End If
rs.MoveNext
Loop
which works but it returns all the ROWS and I want to limit it to the ROWS for the end user.
ANy ideas?
I want to be able to pass a parameter to this to limit the number of rows returned as once the database gets growing it could be quite large.
I tried doing this
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("ListSalesAll")
qdf!formtype = "A"
qdf!Formsalesperson = pubUserName
qdf.Execute
qdf.Close
Set qdf = Nothing
Set dbs = Nothing
WHich worked on an update query but it doesn't seem to like a "SELECT" query, and besides I wasn't sure how to process each row returned.
I then tried this
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim strSQL As String
Set db = CurrentDb
strSQL = "ListSalesAll"
Set rs = db.OpenRecordset(strSQL)
Do While Not rs.EOF
If rs!TypeMain <> "A" Then
'exit
Else
If rs!CopyRecord Then
'do something here
Else
'exit
End If
End If
rs.MoveNext
Loop
which works but it returns all the ROWS and I want to limit it to the ROWS for the end user.
ANy ideas?