PC Review


Reply
Thread Tools Rate Thread

Delete query - delete from specified tables error

 
 
klkropf
Guest
Posts: n/a
 
      3rd Feb 2010
I am running a delete query and am getting the error "could not delete from
specified table". I have looked at the other entries on this, but still
can't figure out what I'm doing wrong. Below is the SQL.


DELETE tblDemotionFY10.*, tblQuarters.Quarter
FROM tblQuarters INNER JOIN tblDemotionFY10 ON tblQuarters.MonthNumber =
tblDemotionFY10.MonthNumber
WHERE (((tblQuarters.Quarter)=[Enter Quarter]));

Thanks!
 
Reply With Quote
 
 
 
 
Jerry Whittle
Guest
Posts: n/a
 
      3rd Feb 2010
You are trying to delete from two tables at once. That's very hard to do with
Access. If you have the tables joined in the Relationship window with
Referential Integrity enabled, you could enable Cascade Delete. Then if you
deleted a record from the parent table, matching records in the child table
would also be deleted.

Otherwise it's a two step process where you delete records from the child
table first, then delete records from the parent table.

This assumes that you really want to delete records from both tables. That's
how the SQL reads. If you only want to delete records from one table, tell us
which table and we could help.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"klkropf" wrote:

> I am running a delete query and am getting the error "could not delete from
> specified table". I have looked at the other entries on this, but still
> can't figure out what I'm doing wrong. Below is the SQL.
>
>
> DELETE tblDemotionFY10.*, tblQuarters.Quarter
> FROM tblQuarters INNER JOIN tblDemotionFY10 ON tblQuarters.MonthNumber =
> tblDemotionFY10.MonthNumber
> WHERE (((tblQuarters.Quarter)=[Enter Quarter]));
>
> Thanks!

 
Reply With Quote
 
klkropf
Guest
Posts: n/a
 
      3rd Feb 2010
I only want to delete records from one table, tblDemotionFY10.

"Jerry Whittle" wrote:

> You are trying to delete from two tables at once. That's very hard to do with
> Access. If you have the tables joined in the Relationship window with
> Referential Integrity enabled, you could enable Cascade Delete. Then if you
> deleted a record from the parent table, matching records in the child table
> would also be deleted.
>
> Otherwise it's a two step process where you delete records from the child
> table first, then delete records from the parent table.
>
> This assumes that you really want to delete records from both tables. That's
> how the SQL reads. If you only want to delete records from one table, tell us
> which table and we could help.
> --
> Jerry Whittle, Microsoft Access MVP
> Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
>
>
> "klkropf" wrote:
>
> > I am running a delete query and am getting the error "could not delete from
> > specified table". I have looked at the other entries on this, but still
> > can't figure out what I'm doing wrong. Below is the SQL.
> >
> >
> > DELETE tblDemotionFY10.*, tblQuarters.Quarter
> > FROM tblQuarters INNER JOIN tblDemotionFY10 ON tblQuarters.MonthNumber =
> > tblDemotionFY10.MonthNumber
> > WHERE (((tblQuarters.Quarter)=[Enter Quarter]));
> >
> > Thanks!

 
Reply With Quote
 
Jerry Whittle
Guest
Posts: n/a
 
      3rd Feb 2010
Try this on a backup copy of the database / tables!:

DELETE tblDemotionFY10.*
FROM tblDemotionFY10
WHERE tblDemotionFY10.MonthNumber
In (SELECT tblQuarters.MonthNumber
FROM tblQuarters
WHERE tblQuarters.Quarter=[Enter Quarter]);
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"klkropf" wrote:

> I only want to delete records from one table, tblDemotionFY10.
>
> "Jerry Whittle" wrote:
>
> > You are trying to delete from two tables at once. That's very hard to do with
> > Access. If you have the tables joined in the Relationship window with
> > Referential Integrity enabled, you could enable Cascade Delete. Then if you
> > deleted a record from the parent table, matching records in the child table
> > would also be deleted.
> >
> > Otherwise it's a two step process where you delete records from the child
> > table first, then delete records from the parent table.
> >
> > This assumes that you really want to delete records from both tables. That's
> > how the SQL reads. If you only want to delete records from one table, tell us
> > which table and we could help.
> > --
> > Jerry Whittle, Microsoft Access MVP
> > Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
> >
> >
> > "klkropf" wrote:
> >
> > > I am running a delete query and am getting the error "could not delete from
> > > specified table". I have looked at the other entries on this, but still
> > > can't figure out what I'm doing wrong. Below is the SQL.
> > >
> > >
> > > DELETE tblDemotionFY10.*, tblQuarters.Quarter
> > > FROM tblQuarters INNER JOIN tblDemotionFY10 ON tblQuarters.MonthNumber =
> > > tblDemotionFY10.MonthNumber
> > > WHERE (((tblQuarters.Quarter)=[Enter Quarter]));
> > >
> > > Thanks!

 
Reply With Quote
 
klkropf
Guest
Posts: n/a
 
      3rd Feb 2010
Perfect! Thank you so much.

"Jerry Whittle" wrote:

> Try this on a backup copy of the database / tables!:
>
> DELETE tblDemotionFY10.*
> FROM tblDemotionFY10
> WHERE tblDemotionFY10.MonthNumber
> In (SELECT tblQuarters.MonthNumber
> FROM tblQuarters
> WHERE tblQuarters.Quarter=[Enter Quarter]);
> --
> Jerry Whittle, Microsoft Access MVP
> Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
>
>
> "klkropf" wrote:
>
> > I only want to delete records from one table, tblDemotionFY10.
> >
> > "Jerry Whittle" wrote:
> >
> > > You are trying to delete from two tables at once. That's very hard to do with
> > > Access. If you have the tables joined in the Relationship window with
> > > Referential Integrity enabled, you could enable Cascade Delete. Then if you
> > > deleted a record from the parent table, matching records in the child table
> > > would also be deleted.
> > >
> > > Otherwise it's a two step process where you delete records from the child
> > > table first, then delete records from the parent table.
> > >
> > > This assumes that you really want to delete records from both tables. That's
> > > how the SQL reads. If you only want to delete records from one table, tell us
> > > which table and we could help.
> > > --
> > > Jerry Whittle, Microsoft Access MVP
> > > Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
> > >
> > >
> > > "klkropf" wrote:
> > >
> > > > I am running a delete query and am getting the error "could not delete from
> > > > specified table". I have looked at the other entries on this, but still
> > > > can't figure out what I'm doing wrong. Below is the SQL.
> > > >
> > > >
> > > > DELETE tblDemotionFY10.*, tblQuarters.Quarter
> > > > FROM tblQuarters INNER JOIN tblDemotionFY10 ON tblQuarters.MonthNumber =
> > > > tblDemotionFY10.MonthNumber
> > > > WHERE (((tblQuarters.Quarter)=[Enter Quarter]));
> > > >
> > > > Thanks!

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Query - Delete matching records from 2 tables - Access 2000 Chris Stammers Microsoft Access Queries 4 22nd Jan 2009 02:45 PM
Delete Query Error "Can't delete from specified tables Maureen227 Microsoft Access Queries 4 26th Jul 2006 04:58 PM
Delete Query Error "Can't delete from specified tables Maureen227 Microsoft Access 6 26th Jul 2006 03:36 PM
Delete query error "Could not delete from specified tables" =?Utf-8?B?UXVhbnR1bUxlYXA=?= Microsoft Access Queries 1 28th Jun 2006 09:56 PM
Delete query (joined 3 tables) could not delete from specified tab =?Utf-8?B?c3BsYXQ=?= Microsoft Access Queries 2 15th May 2005 10:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:15 AM.