B
BruceM
I am working on loading a recordset at runtime, and modifying the recordset
as needed. The default recordset will typically return about 10 records out
of a few hundred or thousand. The default recordset consists of records in
which a FinalApproval (Number) field is Null. A modified recordset may
consist of all records, final approval completed or not, for a department
(one of the fields in the recordset) within a certain date range, to use one
example.
I can write a query to which I apply criteria as needed. For instance, in
the form's Load event:
Dim strSQL as String
strSQL = "SELECT * FROM qryMain WHERE [FinalApproval] Is Null"
Me.Recordsource = strSQL
When I want to see all records for the Accounting department:
Dim strSQL as String
strSQL = "SELECT * FROM qryMain WHERE [Dept] = 'Accounting' "
Me.Recordsource = strSQL
The other choice would be to build the recordset in VBA rather than using a
named query:
strSQL = "SELECT [Dept], [StartDate], [EndDate], [FinalApproval] FROM
tblMain "
strSQL = strSQL & "WHERE [FinalApproval] Is Null"
This is greatly simplified. The actual SQL would be in the neighborhood of
500 - 1000 characters, depending on the parameters.
I can build the SQL string in VBA. The question is whether there is are
arguments one way or the other about using a named query rather than
building the string from constants, user choices (about Department, dates,
etc.), and so forth.
as needed. The default recordset will typically return about 10 records out
of a few hundred or thousand. The default recordset consists of records in
which a FinalApproval (Number) field is Null. A modified recordset may
consist of all records, final approval completed or not, for a department
(one of the fields in the recordset) within a certain date range, to use one
example.
I can write a query to which I apply criteria as needed. For instance, in
the form's Load event:
Dim strSQL as String
strSQL = "SELECT * FROM qryMain WHERE [FinalApproval] Is Null"
Me.Recordsource = strSQL
When I want to see all records for the Accounting department:
Dim strSQL as String
strSQL = "SELECT * FROM qryMain WHERE [Dept] = 'Accounting' "
Me.Recordsource = strSQL
The other choice would be to build the recordset in VBA rather than using a
named query:
strSQL = "SELECT [Dept], [StartDate], [EndDate], [FinalApproval] FROM
tblMain "
strSQL = strSQL & "WHERE [FinalApproval] Is Null"
This is greatly simplified. The actual SQL would be in the neighborhood of
500 - 1000 characters, depending on the parameters.
I can build the SQL string in VBA. The question is whether there is are
arguments one way or the other about using a named query rather than
building the string from constants, user choices (about Department, dates,
etc.), and so forth.