You can bind a view, table function, or stored procedure to a subform instead of a form object. The query will display as a datasheet. Access instantiates a form behind the scenes, adds appropriate controls, and displays the form in datasheet view.
In the datasheet, you can right-click and select various filters: Filter By Selection, Filter Excluding Selection, Filter For, and so on.
After applying some filters, it would be really nice to use the underlying filtered recordset in some reports. This would work as a poor-man's ultimate report filter function, by allowing a user to filter on any column for any value and then use as the source for the report. However, Access (ADP) is doing the filtering differently than the usual Recordset.Filter. I say "poor-man's" because the client is paying very little, needs the answer very soon, and expects a lot. I don't have time to write a big report filter form that can handle any data type and filter type.
Browsing the datasheet's properties reveals some interesting things:
- The underlying recordset is not filtered.
- Form.Recordset.Filter = 0.
- Form.RecordCount is the original record count, not the filtered one.
- Form.CurrentRecord does show the filtered value, starting at 1.
- Form.Recordset.AbsolutePosition moves around to the value of the underlying recordset as you select each filtered record. So if the original recordset has 3000 records, when you click on filtered record 1 it might be 2892 from the original recordset.
- Form.RowHeight and Form.Controls(x).ColumnHeight work as normal for datasheets.
- Form.SelTop and SelHeight work normally.
- Setting a report's RecordSet property to the datasheet's recordset works, but it is also not filtered.
- When two adjacent records from the underlying recordset are both visible in the filtered recordset, issuing a MoveNext or a MovePrevious works: the next or previous filtered record becomes selected. Issuing a MoveNext or MovePrevious does nothing if the next (or previous) underlying record is not in the filtered recordset.
- A quick test against a filtered continuous subform indicates similar behavior: the filtered records are fewer than the underlying recordset which has no .Filter applied.
- Applying a filter to the underlying recordset works and doesn't remove the record from the displayed records.
I suspect that Access is using a clone or copy of the original recordset and synchronizing the two somehow.
Does anyone have any ideas? Here are mine:
- Somehow get access to the datasheet filter text and use it as a WHERE clause on the report. I don't know how to do this.
- Somehow get access to the actual filtered recordset and use that. I don't know how to do this.
- Step through the datasheet, and knowing the key columns, extract the information necessary to duplicate the filter in the report. I haven't been able to figure out how to do this.
... And now the filter's aren't working on the datasheet, when they were before, giving the message for any filter I try, "Cannot apply Filter on one or more fields specified in the Filter property." I don't think I changed anything that could cause this.
Help? Please? Thank you!!!!
In the datasheet, you can right-click and select various filters: Filter By Selection, Filter Excluding Selection, Filter For, and so on.
After applying some filters, it would be really nice to use the underlying filtered recordset in some reports. This would work as a poor-man's ultimate report filter function, by allowing a user to filter on any column for any value and then use as the source for the report. However, Access (ADP) is doing the filtering differently than the usual Recordset.Filter. I say "poor-man's" because the client is paying very little, needs the answer very soon, and expects a lot. I don't have time to write a big report filter form that can handle any data type and filter type.
Browsing the datasheet's properties reveals some interesting things:
- The underlying recordset is not filtered.
- Form.Recordset.Filter = 0.
- Form.RecordCount is the original record count, not the filtered one.
- Form.CurrentRecord does show the filtered value, starting at 1.
- Form.Recordset.AbsolutePosition moves around to the value of the underlying recordset as you select each filtered record. So if the original recordset has 3000 records, when you click on filtered record 1 it might be 2892 from the original recordset.
- Form.RowHeight and Form.Controls(x).ColumnHeight work as normal for datasheets.
- Form.SelTop and SelHeight work normally.
- Setting a report's RecordSet property to the datasheet's recordset works, but it is also not filtered.
- When two adjacent records from the underlying recordset are both visible in the filtered recordset, issuing a MoveNext or a MovePrevious works: the next or previous filtered record becomes selected. Issuing a MoveNext or MovePrevious does nothing if the next (or previous) underlying record is not in the filtered recordset.
- A quick test against a filtered continuous subform indicates similar behavior: the filtered records are fewer than the underlying recordset which has no .Filter applied.
- Applying a filter to the underlying recordset works and doesn't remove the record from the displayed records.
I suspect that Access is using a clone or copy of the original recordset and synchronizing the two somehow.
Does anyone have any ideas? Here are mine:
- Somehow get access to the datasheet filter text and use it as a WHERE clause on the report. I don't know how to do this.
- Somehow get access to the actual filtered recordset and use that. I don't know how to do this.
- Step through the datasheet, and knowing the key columns, extract the information necessary to duplicate the filter in the report. I haven't been able to figure out how to do this.
... And now the filter's aren't working on the datasheet, when they were before, giving the message for any filter I try, "Cannot apply Filter on one or more fields specified in the Filter property." I don't think I changed anything that could cause this.
Help? Please? Thank you!!!!