Link to home
Start Free TrialLog in
Avatar of Dustin Stanley
Dustin Stanley

asked on

MS Access DELETE Query Parameter Error Not Finding Query Field

I am trying to make a DELETE query. I want to DELETE all fields in a table for every record found in a query.

Query:
DELETE *
FROM ImportChildrenPartsCSV
WHERE (ImportChildrenPartsCSV.IDKey)=[qryImportFindDuplicatesDELETE].[IDKey];

Open in new window


(ImportChildrenPartsCSV.IDKey) is the table
and
[qryImportFindDuplicatesDELETE].[IDKey] is the query

Everytime I run it. It asks for the parameter for
[qryImportFindDuplicatesDELETE].[IDKey]

Thought this was pretty straight forward but I don't get it. Thanks for the help.
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Pls try ..

This will delete all the rows from the table..based on matching Ids. * is not required in delete syntax.

DELETE FROM ImportChildrenPartsCSV
WHERE (ImportChildrenPartsCSV.IDKey)=[qryImportFindDuplicatesDELETE].[IDKey];

Open in new window

What is this qryImportFindDuplicatesDELETE ? You need to provide a parameter or a query there to get the IDKey
Avatar of Dustin Stanley
Dustin Stanley

ASKER

I thank you for the help.

What is this qryImportFindDuplicatesDELETE ?

It is a query to find duplicate information in my tables before  I append records from Table ImportChildrenPartsCSV into Table SKUs

Query named qryImportFindDuplicatesDELETE :
SELECT ImportChildrenPartsCSV.IDKey, ImportChildrenPartsCSV.SkuMPN, ImportChildrenPartsCSV.SkuNm, SKUs.ManuID
FROM SKUs INNER JOIN ImportChildrenPartsCSV ON SKUs.SkuMPN = ImportChildrenPartsCSV.SkuMPN
WHERE (((SKUs.ManuID)=[Forms]![frmImportForm]![txtManuID]));

Open in new window

SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok I am sorry but you lost me. I pasted the above code into a query and it is asking for parameter for "K"

I for sure know there are 2 duplicates at this time. How do I run this properly?

If the K is the Key column then wouldn't that be IDKey?

Thanks for the help.
K was an alias for ImportChildrenPartsCSV ..anyway pls try below-

DELETE FROM ImportChildrenPartsCSV
INNER JOIN 
(SELECT ImportChildrenPartsCSV.IDKey
FROM SKUs INNER JOIN ImportChildrenPartsCSV ON SKUs.SkuMPN = ImportChildrenPartsCSV.SkuMPN
WHERE (((SKUs.ManuID)=[Forms]![frmImportForm]![txtManuID]))) as qryImportFindDuplicatesDELETE
ON (ImportChildrenPartsCSV.IDKey) = [qryImportFindDuplicatesDELETE].[IDKey] ; 

Open in new window

Now it is asking for me to: Specify the table containing the records you want to delete.

Which would be the ImportChildrenPartsCSV Table
How r u executing this  ?

Go to the query window and then try.
I have went to Design then Run and I have saved it and clicked on the query name in the side panel.
Both same results.
NO go to the SQL query window and then execute it using Exclamation mark. (!)
This I have tried
User generated image
I am pretty sure I just got. I examined both the tables and relationships and there was a small flaw in naming.
According to that link I am doing it as supposed to.  I don't know if this helps but this is my qryImportFindDuplicatesDELETE Query:
User generated image

SQL:
SELECT ImportChildrenPartsCSV.SkuMPN, ImportChildrenPartsCSV.SkuNm, SKUs.ManuID, ImportChildrenPartsCSV.IDKey
FROM SKUs INNER JOIN ImportChildrenPartsCSV ON SKUs.SkuMPN = ImportChildrenPartsCSV.SkuMPN
WHERE (((SKUs.ManuID)=[Forms]![frmImportForm]![txtManuID]));

Open in new window




Whatever the issue is it involves this part:

WHERE [ImportChildrenPartsCSV].[skumpn]=[qryImportFindDuplicatesDELETE].[IDKey];

Open in new window


more specifically:
[qryImportFindDuplicatesDELETE].[IDKey];

Open in new window



I have thrown several things at it and no matter what it always comes back to asking for a parameter for :
[qryImportFindDuplicatesDELETE].[IDKey];

Open in new window


I have tried other tables and queries such as:
SKUs table with known parameters
[SKUs].[skumpn];

Open in new window


a newly made table with the data put in directly.
[Table1].[IDKey];

Open in new window



I have just make a select query for testing and it still is failing:
SELECT ImportChildrenPartsCSV.IDKey
FROM ImportChildrenPartsCSV
WHERE (((ImportChildrenPartsCSV.IDKey)=[Table1].[IDKey]))

Open in new window


But without the WHERE criteria it SELECTS perfectly:
SELECT ImportChildrenPartsCSV.IDKey
FROM ImportChildrenPartsCSV

Open in new window


It can't find any of them........

I have even compacted and repaired the database.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
PERFECT! THANKS!