-3

How can I create an Access database that deletes entries after specific dates? For example, the expiry date of a medicine in my stock is today. The entry of that medicine must be automatically deleted from my database after today.

**

what macro programming must I do?????

**

malberts
  • 2,488
  • 1
  • 11
  • 16
  • When you ask the question here then you have to provide some snippets of your code so can others will get idea and give the solution – Yogesh Patel Feb 11 '19 at 11:59
  • Deleting records should be a rare event in a db. Better to filter records. Even 'expired' data can often be useful in data analysis. – June7 Feb 11 '19 at 14:06

1 Answers1

0

I wouldn't advise you to delete your records for expired products. You'll probably have old that which will be depending on these records.

You could build a query that shows only valid products, in this case filtering out the expired ones. Then use this new query as your record source in all your data objects. This way your preserve your data for historic purposes and reporting.

Another alternative is to add an Active Yes/No field, with default set to Yes. You can update the expired products to No. Again you would need to filter out the inactive products.

If you choose to go your way, you need to build aDelete Query which will delete the expired products. You can then build a macro/VBA which runs this query. You can then create a Scheduled Task to run the macro once at the start of the day (e.g. 0:00 Midnight). See this related question for information on doing it. Running Microsoft Access as a Scheduled Task

jbud
  • 694
  • 5
  • 7