Delete query

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

Guest

I want to Delete data that is 548 days from Date() on close in a form. I can
create a query statement <Date-548 but how do I get the delete part?
 
I want to Delete data that is 548 days from Date() on close in a form. I can
create a query statement <Date-548 but how do I get the delete part?

CurrentDb.Execute "DELETE * FROM mytable WHERE [datefield] <
DateAdd("d", -548, Date())"

John W. Vinson[MVP]
 
Thanks John.

Is this a query or Macro. If it a Macro I am not familiar to setting those
up. Would you elaborate more on how and where I set them up?

John Vinson said:
I want to Delete data that is 548 days from Date() on close in a form. I can
create a query statement <Date-548 but how do I get the delete part?

CurrentDb.Execute "DELETE * FROM mytable WHERE [datefield] <
DateAdd("d", -548, Date())"

John W. Vinson[MVP]
 
Thanks John.

Is this a query or Macro. If it a Macro I am not familiar to setting those
up. Would you elaborate more on how and where I set them up?

Sorry, this was VBA code.

Just create a Delete query in the query design window. Put

< DateAdd("d", -548, Date())

on the Criteria line under the date field that you wish to search.

You can then run the query manually, or from a Macro or from VBA code.


John W. Vinson[MVP]
 
Back
Top