Correlated subquery in DELETE stmt not work in Access '97 or 2000 
Author Message
 Correlated subquery in DELETE stmt not work in Access '97 or 2000

Hi,

I cross-posted a version of this to the comp.databases.ms-access ng, but this
post is more specific to VB which is what I am using, along with Access.

I have the following query that I think should work in Access:

DELETE * FROM ABAMaster AS A WHERE NOT EXISTS (SELECT * FROM ACCOUNTHEADER
WHERE ABANUM = A.ABANUM);

*** I have tried many variations of the aobve SQL, but to no avail.

I get the following error when I run it in both Access '97 and Access 2000:

                               Invalid argument. (Error 3001)

The text of the error message follows:

Quote:
>You tried to perform an operation that involves a routine in a DLL, and one of
the
>arguments to the routine is invalid. Check your entry to make sure you have
>specified the correct arguments, and then try the operation again.

>This error also occurs when you attempt to use mutually exclusive constants in
>an argument to a method, such as specifying both dbConsistent and
>dbInconsistent in the options argument to the OpenRecordset method.

I get the same error if use "NOT IN" in place of "NOT EXISTS". This should be a
simple operation: delete all rows from TableA which do not have a related row
in TableB, but Access is giving me a fit.

I was exec'ing this via an ADODB call in VB 6.0. I switched over the Access to
try the query there. In both places, I get the same error.

Do I need to update some data access component of NT or '98 that Access uses?
Anybody else out there have a similar problem. I search MS' knowledge base to
no avail. I used www.deja.com to no avail as well.

Thanks,
Greg



Tue, 17 Dec 2002 03:00:00 GMT  
 Correlated subquery in DELETE stmt not work in Access '97 or 2000
Try this variation:

DELETE * FROM ABAMaster
WHERE ABANUM = (SELECT ABANUM FROM ACCOUNTHEADER);

Hope this helps,

Bruce

Quote:

>I have the following query that I think should work in Access:

>DELETE * FROM ABAMaster AS A WHERE NOT EXISTS (SELECT * FROM ACCOUNTHEADER
>WHERE ABANUM = A.ABANUM);

>*** I have tried many variations of the aobve SQL, but to no avail.

>I get the following error when I run it in both Access '97 and Access 2000:

>                               Invalid argument. (Error 3001)

>The text of the error message follows:

>>You tried to perform an operation that involves a routine in a DLL, and
one of
>the
>>arguments to the routine is invalid. Check your entry to make sure you
have
>>specified the correct arguments, and then try the operation again.

>>This error also occurs when you attempt to use mutually exclusive
constants in

>>an argument to a method, such as specifying both dbConsistent and
>>dbInconsistent in the options argument to the OpenRecordset method.

>I get the same error if use "NOT IN" in place of "NOT EXISTS". This should
be a
>simple operation: delete all rows from TableA which do not have a related
row
>in TableB, but Access is giving me a fit.



Wed, 18 Dec 2002 03:00:00 GMT  
 Correlated subquery in DELETE stmt not work in Access '97 or 2000
This is a no go as MS-Access reports that only one row can be returned form the
subquery. To do what I needed, I had to mod it to read:

DELETE * FROM ABAMaster WHERE ABANUM <> (SELECT ABANUM FROM ACCOUNTHEADER);

Someone else used the QB function of Access to come up with

DELETE exists (Select * from AccountHeader where ABANum = A.ABANUM) AS Expor1,
*
FROM ABAMASTER AS A
WHERE (((Exists (Select * From AccountHeader Where ABANUM = A.ABANUM)) =
False));

Unfortunately, this query gives me the same error "Invalid argument. (Error
3001)"

Anybody got any other ideas? Is there a patch I need to apply to a data access
component of Windows or anything like that?

Thanks,
Greg

Quote:
>Try this variation:

>DELETE * FROM ABAMaster
>WHERE ABANUM = (SELECT ABANUM FROM ACCOUNTHEADER);

>Hope this helps,

>Bruce
>Try this variation:

>DELETE * FROM ABAMaster
>WHERE ABANUM = (SELECT ABANUM FROM ACCOUNTHEADER);

>Hope this helps,

>Bruce


>>I have the following query that I think should work in Access:

>>DELETE * FROM ABAMaster AS A WHERE NOT EXISTS (SELECT * FROM ACCOUNTHEADER
>>WHERE ABANUM = A.ABANUM);

>>*** I have tried many variations of the aobve SQL, but to no avail.

>>I get the following error when I run it in both Access '97 and Access 2000:

>>                               Invalid argument. (Error 3001)

>>The text of the error message follows:

>>>You tried to perform an operation that involves a routine in a DLL, and
>one of
>>the
>>>arguments to the routine is invalid. Check your entry to make sure you
>have
>>>specified the correct arguments, and then try the operation again.

>>>This error also occurs when you attempt to use mutually exclusive
>constants in

>>>an argument to a method, such as specifying both dbConsistent and
>>>dbInconsistent in the options argument to the OpenRecordset method.

>>I get the same error if use "NOT IN" in place of "NOT EXISTS". This should
>be a
>>simple operation: delete all rows from TableA which do not have a related
>row
>>in TableB, but Access is giving me a fit.



Sun, 22 Dec 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. DLL usage - works in Access 97 but not in Access 2000

2. Program from access 97 won't work in access 2000

3. Link Failure in Access 2000 that works in Access 97

4. Getting back the formatted MsgBox in Access 2000 that worked in Access 97

5. Access 97 VBA modifications not visible in Access 2000

6. Access 2000 can't read from a referenced table - but could in Access 97

7. Why does this piece of code work with Word 97 but not Word 2000

8. Excel Macro from Office 97 won't work in 2000

9. How to get Access 97 (built on a Windows 2000) to work on 95s and 98s

10. Best method of working with Access 97 / Outlook 2000 / Exchange Server 5.5

11. converting from access 2000 to '97

12. Possible use of Sheridan's data widgets in Access 97/2000

 

 
Powered by phpBB® Forum Software