delete records macro?

T

tradmusic

Hi,

Is it possible to set up a query / macro that automatically deletes records
held in a particular query table?

For example, I wanted to have a Yes/No field in my database that would
basically be an Include / Delete option - if ticked, then that record would
be pulled into a query table of Deleted records.

Of course, they're not deleted, they are just marked as such - so is it
possible to then create a command that will delete out, maybe weekly or
something, all records held in the Deleted Records query table?

Hope that makes sense!
Nath.
 
S

Steve Schapel

Nath,

You just need a Delete Query for this. Make a new query in design view,
based on your table. Drag the * from the table into the Field row of
the first column in the grid, and then put the Yes/No field also into
the grid. In the criteria of the Yes/No field put -1. Make it into a
Delete Query (select Delete from the Query menu). In the Delete row of
the grid, leave From in the * column, and put Where in the Yes/No
field's column. Run the query... viola! To automate the process, for
example make it happen on the click of a command button, make a macro
using the OpenQuery action. After you are sure it is working correctly,
you might want to also put a SetWarnings,No action before the OpenQuery
action, to suppress the display of the action query confirmation messages.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top