473,396 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Could not delete from specified tables. (Error 3086)

Hi
Have looked through many forums but cannot find a solution for this.

I have a table where i store certain dates [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 [DATES].
Example of my query :

DELETE ALLAccounts18MONTHS.*, ALLAccounts18MONTHS.Date
FROM ALLAccounts18MONTHS, DATES
WHERE (((ALLAccounts18MONTHS.Date) Between [DATES]![CurrWeek78StartDate] And [DATES]![CurrWeek78EndDate]));

ALLAccounts18MONTHS is one of the tables i want to delete rows from
DATES is the master file holding dates

Can anyone advise.
Thanks
Martin
Jul 27 '07 #1
5 9647
Rabbit
12,516 Expert Mod 8TB
What do you mean by file?
Jul 27 '07 #2
Sorry
DATES is a master table within the same database.

Thanks
Martin
Jul 31 '07 #3
JKing
1,206 Expert 1GB
Hi, I believe the problem is that you've included the table DATES in your FROM clause. I understand the logic behind placing it there however Access doesn't like it because it's trying to delete from it as well. To get the values you'll need to use subqueries.

Give this a try:
Expand|Select|Wrap|Line Numbers
  1. DELETE ALLAccounts18MONTHS.*, ALLAccounts18MONTHS.Date
  2. FROM ALLAccounts18MONTHS
  3. WHERE ALLAccounts18MONTHS.Date 
  4. BETWEEN (SELECT [CurrWeek78StartDate] FROM DATES) 
  5. AND (SELECT [CurrWeek78EndDate] FROM DATES);
  6.  
Jul 31 '07 #4
JKing

Thank you that works a treat. I am a newbie with SQL, so on a learning curve at the moment.
I can now save myself from editing about 20 queries everyday.
Aug 2 '07 #5
JKing
1,206 Expert 1GB
JKing

Thank you that works a treat. I am a newbie with SQL, so on a learning curve at the moment.
I can now save myself from editing about 20 queries everyday.
It can take a while to learn. Somethings which seem totally logical just aren't always the case. It's good that you are learning your SQL though it's very important. Too many people simply use the design view not knowing about the SQL behind it and run into problems when they need to do complex things.

Good luck and keep at it!

Jking
Aug 2 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: michael | last post by:
Gotta post because this is driving me nuts. Trying to DELETE orphans. I can successfully: SELECT GroupID FROM Groups LEFT JOIN Users ON UsersID = UserID WHERE UsersID IS NULL; but when I...
5
by: Andrew DeFaria | last post by:
I created the following .sql file to demonstrate a problem I'm having. According to the manual: If |ON DELETE CASCADE| is specified, and a row in the parent table is deleted, then InnoDB...
2
by: Bob Ganger | last post by:
Hello, I am working on a project using SQL Server 2000 with a database containing about 10 related tables with a lot of columns containing text. The total current size of the database is about...
2
by: Eric Haskins | last post by:
Ok I upgraded to 4.1.12 Max so I could start using InnoDb and be able to do multiple table deletes among others. I have an app system that I need to delete info from a few tables when we delete...
2
by: Eric Falsken | last post by:
Eric Falsken <eric@db4o.com> wrote on 04 Dec 2005: > craigkenisston@hotmail.com wrote on 19 Nov 2005: > >> I'm working in the migration of an asp.net application in 1.1 to 2.0. >> I'm new to...
3
by: rn5a | last post by:
I am trying to delete records from a MS-Access DB table using the following query: strSQL=DELETE FROM MyTable WHERE =CInt(Request.QueryString("delete")) con.Execute strSQL When I run the app...
8
by: Trevor2007 | last post by:
Hi, I have 2 tables and The VMSU-ILt-Main Table contains info about a person on the main form, the VMSU-ILT-Sub Table contains info about the subform on the main form. they both have as ehe...
0
by: stormogulen | last post by:
Hello all, I'm having some problems understanding how the runtime locates assemblies, and I hope you can help me shed some light on it. I'm deploying a web service, which uses some 3rd party...
5
by: Tony Johansson | last post by:
Hello! Here I have a working program that delete the specified row in the database. It works fine but I want to fully understand it. In this example the SQLCommandBuilder will automatically...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.