B
BruceM
I'm trying to come up with a strategy for limiting the initial recordset to
just the records that have been completed, but allowing the user the option
of viewing all records. This intial recordset would be for all departments,
but I would like to give the user the option of limiting the recordset
according to department. Further, if the user selects all records, there
should be an option of limiting the recordset according to a selected date
range.
I have spoken so far of limiting the recordset rather than filtering it
because I am not sure filtering is the best approach. The database will
generate fewer than 100 records per year, so even though filtering can be
slower than using a WHERE clause, I doubt I will notice much difference.
The form is based on a query that incorporates several tables, including
three separate instances of the same table. The query's SQL is
approximately 1600 characters in length. If I was to use a WHERE clause, I
could either make the SQL string (without a WHERE clause) into a constant
(conSQL), or I could use an asterisk, which I have heard is not such a good
idea.
I can build up the WHERE string using something like the system Allen Browne
described on his web site for filtering a report based on selections in a
multi-select list box, except that I would be using several separate
controls to build the filter. That string (strWhere) could be used either
for filtering or as a SQL WHERE clause. For the SQL, a command button's
Click event could have something like:
dim strSQL as String
strSQL = conSQL & strWhere
Me.Recordsource = strSQL
With an asterisk:
strSQL = "SELECT * FROM qryMain " & strWhere
Me.Recordsource = strSQL
I would in like manner apply a WHERE clause in the form's Open event to
limit the records to ones in which the DateFinal field is null.
Or I could use a filter. In the form's Open event:
Me.Filter = "DateFinal Is Null"
Me.FilterOn = True
Once the form is open, I would build strWhere as described, and use that as
the filter upon demand.
By the way, I can't quite get my mind around why using the asterisk is
considered a bad idea. Maybe I have taken the warning too literally, and
there are circumstances in which it makes sense. Without the asterisk, if I
change the query I will need to make a new SQL string to use as the basis
for the recordsource (if I go that route).
To sum up, I wonder if there are criteria upon which to base the decision to
use either SQL or a filter.
just the records that have been completed, but allowing the user the option
of viewing all records. This intial recordset would be for all departments,
but I would like to give the user the option of limiting the recordset
according to department. Further, if the user selects all records, there
should be an option of limiting the recordset according to a selected date
range.
I have spoken so far of limiting the recordset rather than filtering it
because I am not sure filtering is the best approach. The database will
generate fewer than 100 records per year, so even though filtering can be
slower than using a WHERE clause, I doubt I will notice much difference.
The form is based on a query that incorporates several tables, including
three separate instances of the same table. The query's SQL is
approximately 1600 characters in length. If I was to use a WHERE clause, I
could either make the SQL string (without a WHERE clause) into a constant
(conSQL), or I could use an asterisk, which I have heard is not such a good
idea.
I can build up the WHERE string using something like the system Allen Browne
described on his web site for filtering a report based on selections in a
multi-select list box, except that I would be using several separate
controls to build the filter. That string (strWhere) could be used either
for filtering or as a SQL WHERE clause. For the SQL, a command button's
Click event could have something like:
dim strSQL as String
strSQL = conSQL & strWhere
Me.Recordsource = strSQL
With an asterisk:
strSQL = "SELECT * FROM qryMain " & strWhere
Me.Recordsource = strSQL
I would in like manner apply a WHERE clause in the form's Open event to
limit the records to ones in which the DateFinal field is null.
Or I could use a filter. In the form's Open event:
Me.Filter = "DateFinal Is Null"
Me.FilterOn = True
Once the form is open, I would build strWhere as described, and use that as
the filter upon demand.
By the way, I can't quite get my mind around why using the asterisk is
considered a bad idea. Maybe I have taken the warning too literally, and
there are circumstances in which it makes sense. Without the asterisk, if I
change the query I will need to make a new SQL string to use as the basis
for the recordsource (if I go that route).
To sum up, I wonder if there are criteria upon which to base the decision to
use either SQL or a filter.