Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / September 2005

Tip: Looking for answers? Try searching our database.

Delete Query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
neeraj - 09 Sep 2005 23:42 GMT
I have two queries which I have joined through a field. I am trying to delete
records from one query based on a criteria. I had accomplished this using
joined tables but due to permission issues, I am having to change tables to
queries. I dont know if one can delete records from a query. Can someone help?
S Panja - 10 Sep 2005 10:32 GMT
Define a delete query.

> I have two queries which I have joined through a field. I am trying to delete
> records from one query based on a criteria. I had accomplished this using
> joined tables but due to permission issues, I am having to change tables to
> queries. I dont know if one can delete records from a query. Can someone help?
Steve Schapel - 10 Sep 2005 20:16 GMT
Neeraj,

Yes, you can delete records via a query... as long as it is an
updateable query.  If the nature of the delete query's component
queries, or the nature of the join between them, will mean the query is
non-updateable, you will need to take another approach.  Please post
back with more datails if you need more explicit help.

Signature

Steve Schapel, Microsoft Access MVP

> I have two queries which I have joined through a field. I am trying to delete
> records from one query based on a criteria. I had accomplished this using
> joined tables but due to permission issues, I am having to change tables to
> queries. I dont know if one can delete records from a query. Can someone help?
neeraj - 12 Sep 2005 20:48 GMT
Here is the SQL statement:
DELETE DISTINCTROW [SQ1].*, [SQ1].Field2
FROM [SQ1] INNER JOIN [SQ2] ON [SQ1].Field1 = [SQ2].Field1
WHERE ((([SQ1].Field2)="Val1"));
There are 2 select quesries that I have joined: SQ1 and SQ2 on a field say
Field1. I am trying to delete records from SQ1 based on criteria of
Field2=val1
I have tried with the 'Unique Records' property set to both 'yes' and 'no'
and it doesn't work.

> Neeraj,
>
[quoted text clipped - 8 lines]
> > joined tables but due to permission issues, I am having to change tables to
> > queries. I dont know if one can delete records from a query. Can someone help?
Steve Schapel - 13 Sep 2005 10:49 GMT
Neeraj,

Well, I'd need to see the details of SQ1 and SQ2 to really know what's
going on.  But here's the acid text...  make a normal Select query, like
this:
 SELECT [SQ1].*
 FROM [SQ1] INNER JOIN [SQ2] ON [SQ1].Field1 = [SQ2].Field1
 WHERE ((([SQ1].Field2)="Val1"))
... and see if you can add a new record or edit the data in the query
datasheet.  If not, you are dealing with a non-updateable query.  If
this is the case, you might try something like this...
 DELETE [SQ1].*
 FROM [SQ1]
 WHERE (([SQ1].Field2="Val1") AND ([SQ1].Field1 IN(SELECT Field1 FROM
SQ2)))

Signature

Steve Schapel, Microsoft Access MVP

> Here is the SQL statement:
> DELETE DISTINCTROW [SQ1].*, [SQ1].Field2
[quoted text clipped - 18 lines]
>>>joined tables but due to permission issues, I am having to change tables to
>>>queries. I dont know if one can delete records from a query. Can someone help?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.