Re: help with delete query

From: John Spencer (MVP) (spencer4_at_comcast.net)
Date: 04/30/04


Date: Thu, 29 Apr 2004 20:49:19 -0400

First, I would use field Is Null as my criteria.

DELETE Persons.*
FROM Persons LEFT JOIN EMail
      ON Persons.id = EMail.Id
WHERE [persons].[first] Is Null AND
      [persons].[last] Is Null AND
      [persons].[zip] is Null AND
      [email].[emailaddr] is Null

Second, I would check that the SQL was as above and not

DELETE * ...

or

DELETE Persons.*, * ...

Those two statements both have a problem in that they refer to more than one table.

Allen Clark wrote:
>
> I have an Access 2000 db with many linked tables. I have determined that if
> the persons.first, persons.last, persons.zip, and email.emailaddr fields are
> all blank, the record was incorrectly entered and I would like to get rid of
> any record that matches these criteria. When I build the delete query, the
> SQL that is generated is as follows:
>
> DELETE Persons.*
> FROM Persons LEFT JOIN EMail ON Persons.id = EMail.Id
> WHERE (((IsNull([persons].[first]))<>False) AND
> ((IsNull([persons].[last]))<>False) AND ((IsNull([persons].[zip]))<>False)
> AND ((IsNull([email].[emailaddr]))<>False));
>
> If this same selection criteria is used in a simple query with a left outer
> join, and select only the Persons.ID field, I get a listing of 1676 records.
> If I convert it to a delete query, the only message I get is "could not
> delete from specified tables".
>
> Any ideas on what is going on here?
>
> Thanks in advance,
> Allen



Relevant Pages

  • Re: SQL Syntax Error
    ... match all the criteria you input. ... SQL view and never open it in the query grid view. ... The syntax for the "where" statement is incorrect becuase of this. ...
    (microsoft.public.access.queries)
  • Re: Using combo box to search form
    ... "Jeff Boyce" wrote: ... Since you "started adding" additional criteria, ... about SQL syntax to know how to form a grammatically-correct SQL statement. ... One way to do that is to see what Access generates when you build a query. ...
    (microsoft.public.access.formscoding)
  • Re: Adjusting SQL in Query
    ... from the RESPEL table which satisfy the criteria in the PRICELIST Table. ... RESPEL INNER JOIN PRICELIST ON RESPEL.PRICELIST = ... Subject: Adjusting SQL in Query ...
    (microsoft.public.access.queries)
  • Re: Using combo box to search form
    ... Since you "started adding" additional criteria, ... about SQL syntax to know how to form a grammatically-correct SQL statement. ... One way to do that is to see what Access generates when you build a query. ... Dim strWhere As String ...
    (microsoft.public.access.formscoding)
  • Re: Use adp form control as criteria for sql function
    ... This ADP Magic is very simple but requires syncronizing your naming convention between the MS SQL parameter names on the back end ... You don't have to make a requery after setting the record source. ... user must KNOW what to enter into the parameter query prompt. ... there are up to 10 different types of criteria, ...
    (microsoft.public.access.adp.sqlserver)