delete record if "date" < "today"

  • Thread starter Thread starter Wax
  • Start date Start date
W

Wax

I have a database which is updated from a web site form.
One of the manditor fields in the form is a "good till
date" field. At present I'm sorting the database by this
field each day and manually deleting the records prior to
todays date. Is it possible to have a record
automatically deleted when a "date" field is less
than "today"
 
Wax,

Make a query on the table, and add the Good till Date field in the grid
(plus as amny others as you want, it's immaterial). In the first criterion
line under this field, type in the following expression:
<Date()
This query will return all fields where the said date is older than today;
switch to datasheet view to verify. Back to the design view, go to menu item
Query > Delete Query. Running the query now (Query > Run while in design
view, double-clicking in the db window) will delete all the records
satisfying the criterion.
You could automate the process by setting up a simple macro with an
OpenQuery action, and naming the macro Autoexec. This will make the macro
run every time you open the database. Alternatively, you could use a command
button on a form (or a switchboard) to run the query whenever desired.

HTH,
Nikos
 
Back
Top