473,749 Members | 2,636 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Selective deletion - delete records based on dates


Dear all,

I'm trying to do a selective deletion from an 'Archive' table based on
dates.

Here is the setup:

Table 'Archive' has a date field ( [DateArchive] ).
Another table ('Cutoffs') defines the Low and High Cut-off dates
(fields: [DateCutoff_Low], [DateCutoff_Hi] respectively).

The logic is:

We want to delete all the records from the Archive table where:
[DateArchive] >= [DateCutoff_Low] OR [DateArchive] <=
[DateCutoff_Hi]

The closest I've got (using the Access GUI) generates this SQL:

DELETE
Archive.*, Archive.DateArc hive
FROM
Archive, Cutoffs
WHERE
(((Archive.Date Archive)>=[Cutoffs]![DateCutOff_Low]
Or
(Archive.DateAr chive)<=[Cutoffs]![Date_CutOff_Hi]));

This generates a 'Could not delete from specified tables' error.

Any insights for this?

Many thanks,
Alex

Feb 23 '07 #1
4 3161
On Feb 23, 8:02 am, "alex.hatzisava s" <alex.hatzisa.. .@gmail.com>
wrote:
Dear all,

I'm trying to do a selective deletion from an 'Archive' table based on
dates.

Here is the setup:

Table 'Archive' has a date field ( [DateArchive] ).
Another table ('Cutoffs') defines the Low and High Cut-off dates
(fields: [DateCutoff_Low], [DateCutoff_Hi] respectively).

The logic is:

We want to delete all the records from the Archive table where:
[DateArchive] >= [DateCutoff_Low] OR [DateArchive] <=
[DateCutoff_Hi]

The closest I've got (using the Access GUI) generates this SQL:

DELETE
Archive.*, Archive.DateArc hive
FROM
Archive, Cutoffs
WHERE
(((Archive.Date Archive)>=[Cutoffs]![DateCutOff_Low]
Or
(Archive.DateAr chive)<=[Cutoffs]![Date_CutOff_Hi]));

This generates a 'Could not delete from specified tables' error.

Any insights for this?

Many thanks,
Alex

Check your syntax for field name consistency.

Feb 24 '07 #2
On Feb 24, 6:55 pm, lgeastw...@gmai l.com wrote:
On Feb 23, 8:02 am, "alex.hatzisava s" <alex.hatzisa.. .@gmail.com>
wrote:
Dear all,
I'm trying to do a selective deletion from an 'Archive' table based on
dates.
Here is the setup:
Table 'Archive' has a date field ( [DateArchive] ).
Another table ('Cutoffs') defines the Low and High Cut-off dates
(fields: [DateCutoff_Low], [DateCutoff_Hi] respectively).
The logic is:
We want to delete all the records from the Archive table where:
[DateArchive] >= [DateCutoff_Low] OR [DateArchive] <=
[DateCutoff_Hi]
The closest I've got (using the Access GUI) generates this SQL:
DELETE
Archive.*, Archive.DateArc hive
FROM
Archive, Cutoffs
WHERE
(((Archive.Date Archive)>=[Cutoffs]![DateCutOff_Low]
Or
(Archive.DateAr chive)<=[Cutoffs]![Date_CutOff_Hi]));
This generates a 'Could not delete from specified tables' error.
Any insights for this?
Many thanks,
Alex

Check your syntax for field name consistency.

The above is just an example to demonstrate the logic, it does not
include the real field names.
Anyhow i believe this has nothing to do with field syntax, but is
related to how Jet SQL handles selective deletions.

Feb 25 '07 #3
On Feb 25, 10:58 am, "alex.hatzisava s" <alex.hatzisa.. .@gmail.com>
wrote:
On Feb 24, 6:55 pm, lgeastw...@gmai l.com wrote:


On Feb 23, 8:02 am, "alex.hatzisava s" <alex.hatzisa.. .@gmail.com>
wrote:
Dear all,
I'm trying to do a selective deletion from an 'Archive' table based on
dates.
Here is the setup:
Table 'Archive' has a date field ( [DateArchive] ).
Another table ('Cutoffs') defines the Low and High Cut-off dates
(fields: [DateCutoff_Low], [DateCutoff_Hi] respectively).
The logic is:
We want to delete all the records from the Archive table where:
[DateArchive] >= [DateCutoff_Low] OR [DateArchive] <=
[DateCutoff_Hi]
The closest I've got (using the Access GUI) generates this SQL:
DELETE
Archive.*, Archive.DateArc hive
FROM
Archive, Cutoffs
WHERE
(((Archive.Date Archive)>=[Cutoffs]![DateCutOff_Low]
Or
(Archive.DateAr chive)<=[Cutoffs]![Date_CutOff_Hi]));
This generates a 'Could not delete from specified tables' error.
Any insights for this?
Many thanks,
Alex
Check your syntax for field name consistency.

The above is just an example to demonstrate the logic, it does not
include the real field names.
Anyhow i believe this has nothing to do with field syntax, but is
related to how Jet SQL handles selective deletions.- Hide quoted text -

- Show quoted text -
Ok the trick is to use an SQL Select statement in the Criteria of the
Delete query, for example as follows:
>=(SELECT tbl_000b_Date_C utoffs.Date_Cut Off_Low FROM tbl_000b_Date_C utoffs)
Or
<=(SELECT tbl_000b_Date_C utoffs.Date_Cut Off_Hi FROM
tbl_000b_Date_C utoffs)
Feb 26 '07 #4
On Feb 25, 10:58 am, "alex.hatzisava s" <alex.hatzisa.. .@gmail.com>
wrote:
On Feb 24, 6:55 pm, lgeastw...@gmai l.com wrote:


On Feb 23, 8:02 am, "alex.hatzisava s" <alex.hatzisa.. .@gmail.com>
wrote:
Dear all,
I'm trying to do a selective deletion from an 'Archive' table based on
dates.
Here is the setup:
Table 'Archive' has a date field ( [DateArchive] ).
Another table ('Cutoffs') defines the Low and High Cut-off dates
(fields: [DateCutoff_Low], [DateCutoff_Hi] respectively).
The logic is:
We want to delete all the records from the Archive table where:
[DateArchive] >= [DateCutoff_Low] OR [DateArchive] <=
[DateCutoff_Hi]
The closest I've got (using the Access GUI) generates this SQL:
DELETE
Archive.*, Archive.DateArc hive
FROM
Archive, Cutoffs
WHERE
(((Archive.Date Archive)>=[Cutoffs]![DateCutOff_Low]
Or
(Archive.DateAr chive)<=[Cutoffs]![Date_CutOff_Hi]));
This generates a 'Could not delete from specified tables' error.
Any insights for this?
Many thanks,
Alex
Check your syntax for field name consistency.

The above is just an example to demonstrate the logic, it does not
include the real field names.
Anyhow i believe this has nothing to do with field syntax, but is
related to how Jet SQL handles selective deletions.- Hide quoted text -

- Show quoted text -
Hi folks

Try

Between DateCutoff_Low And DateCutoff_Hi

in the criteria! Usually works for me!

Feb 27 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6589
by: Tuhin Kumar | last post by:
Hi, I have a requirement on improving the deletion rate on on records of a table. The table contains 5 million records, but since deleting everything matching the condition at one go was giving the ROLLBACK segment allocation error, the query was called in a loop and deleting 2000 rows at one interation. My query is: DELETE FROM Table1 WHERE TimeStamp >= TO_DATE('2003-11-30 18:30:00', 'YYYY-MM-DD HH24:MI:SS') and TimeStamp <=...
2
2565
by: Peter yeshew | last post by:
I have 2 tables, Orders and Order Details, the same as with the database Nortwindtraders shipped with Access. The table order is linked with the table Order Details through the filed OrderID. It is autonumber in the table orders and number in the table Order Details.I have a very good function deleting a chosen order from a list box called ListOrders. This function is the following Public Function CancelOrders() Dim StrSQL As String
4
2028
by: John Baker | last post by:
HI again: I have a query which selects records on tblPOmods on the basis of information on two other tables. I wish to delete the selected transactions, and am having a problem doing it. It tells me that if "could not delete from the specified tables". I have tried to set the "where" to "From" for the fields I selected, but the "From" wont take and bounces back to "where". I have tried other strategies, and got a comment "Identity table...
2
1759
by: Tim Tabor | last post by:
How can I delete records from a table with a criterion that depends on a value in an *unrelated* table? In other words, something like: DELETE tblPortfolioHistory.* FROM tblPortfolioHistory WHERE (((tblPortfolioHistory.Date)=.));
16
2213
by: Lyle Fairfield | last post by:
There is an MS-SQL table named Bugs_Comments_and_Suggestions. There is a form named Bugs_Comments_and_Suggestions. To allow John Doe to use this form, we GRANT him LOGIN and ACCESS permissions to the db and SELECT permissions on the stored procedure which is the record source for the BOUND form. To allow John Doe to "UPDATE, INSERT, DELETE" using the BOUND form, we GRANT John Doe "UPDATE, INSERT, DELETE" permissions on the table,
2
8845
by: Cornelius Buschka | last post by:
Hi, we saw the following problem: We deleted all rows from a table B referencing table A (~500000 records). No problem, but the following try to delete all records from table A (~180000) lead to a "never ending" statement. We found out, that vacuuming table B after delete did the trick. It seems to us the database has to do scan thru deleted records on B while
5
9680
by: MRounds | last post by:
Hi Have looked through many forums but cannot find a solution for this. I have a table where i store certain dates and i want to use this table in several queries to delete records from multiple tables by using a macro to run the queries. I can use DISTINCTROW to delete rows that are equal to a date but cannot figure out how to delete rows that are between a range of dates (stored in . Example of my query : DELETE...
3
2425
by: brucedodds | last post by:
My application has a form based on a parent table with a subform based on a child table. The relationship is Cascade Delete. The first record displayed when the form opens has five child records. The form allows this record to be deleted without a prompt, though SetWarnings is set to True. When you try to delete other records, you do get a prompt. The problem isn't the relationship or the tables, because a test form/ subform using the...
7
3903
by: jmstur2 | last post by:
I have a table with what I consider duplicate records. Data in all columns are duplicate except for the date column, meaning that duplicate data was entered on different dates and those dates were stored along with the data. I want to delete the records except for most recent one. I can select the client ID field and the max(date field) to determine the ones I want to keep, but how do I determine the ones to delete. There are often more than...
0
8997
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8833
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9568
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9389
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6801
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4881
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3320
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2794
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.