A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Delete query



 
 
Thread Tools Display Modes
  #1  
Old September 6th, 2005, 06:14 AM
Nick
external usenet poster
 
Posts: n/a
Default Delete query

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?
  #2  
Old September 6th, 2005, 06:56 AM
John Vinson
external usenet poster
 
Posts: n/a
Default

On Mon, 5 Sep 2005 22:14:01 -0700, "Nick"
wrote:

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]
  #3  
Old September 6th, 2005, 04:30 PM
Nick
external usenet poster
 
Posts: n/a
Default

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" wrote:

On Mon, 5 Sep 2005 22:14:01 -0700, "Nick"
wrote:

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]

  #4  
Old September 6th, 2005, 05:52 PM
John Vinson
external usenet poster
 
Posts: n/a
Default

On Tue, 6 Sep 2005 08:30:19 -0700, "Nick"
wrote:

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]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Toolbars, Drop-Down Menus Rick New Users 1 September 21st, 2005 11:17 AM
Access 2k/2003: Touble with delete query using WHERE EXISTS Darin Running & Setting Up Queries 17 August 25th, 2005 06:58 PM
Delete Query Lou Running & Setting Up Queries 5 May 17th, 2005 06:24 PM
Delete query won't run! faramir Running & Setting Up Queries 7 February 7th, 2005 03:26 AM
Here's a shocker Mike Labosh General Discussion 2 October 26th, 2004 05:04 PM


All times are GMT +1. The time now is 09:05 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.