Delete from Recordset without Affecting Table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Here's the scenario:
I query my database and put all of the records into a recordset
In the recordset is a text field which I parse with a regular expression
This returns among other things a product code
I filter on the product code, and if it doesn't match the product code I
want I want to dump it from the recordset before I open a report and display
the results.

So, how do I remove records (rows) from the recordset without actually
deleting the underlying table data?

One thought was to populate a new recordset with the rows I DO want, but
this seems like overengineering.

Thanks,

-David
 
When you open a recordset based on a table, anything you do to the data will
be done to the table's data.

So you can do one of these things:

(1) Create and save a query that returns the records that you are currently
getting. Base your report on that query (use it as the report's
recordsource). Open the report and pass the filtering string in the fourth
argument of the DoCmd.OpenReport action (the "WhereCondition" argument).

(2) Apply a filter to the current recordset based on the value you seek,
then open a new recordset from the first recordset. You'll still need to
write these data to a new table if you want to use the records in a report,
though.

(3) Your thought of opening a new recordset (based on another table, which
may be a temporary one) and then write the data you want to the new
recordset.
 
So, how do I remove records (rows) from the recordset without actually
deleting the underlying table data?

You don't; a recordset is purely and simply a view of the data in the
table. It has no independent existance.
]
One thought was to populate a new recordset with the rows I DO want, but
this seems like overengineering.

Either do that, or apply a Filter to the report to select only the
desired records; best of all, incorporate the criterion in the
original recordset query criteria, if that's possible.

John W. Vinson[MVP]
 
Back
Top