Link to home
Start Free TrialLog in
Avatar of Aravind Ranganathan
Aravind Ranganathan

asked on

Access Delete Query Not Working

I am working on a query to delete from an existing linked table where the Batch Id is all the same. So my query is as following :

  User generated imageUser generated imagei am using an explicit parameter called BatchID and when i pass 1 into it i want it to delete all the records so that i can load the next batch next time, but when i run the query i am getting could not delete from specified tables?? i am not sure why??
Avatar of Tusitala
Tusitala

Sounds like a relationship issue.

Check for any relationship constraints. Also remove any other fields from your query as there may be dependencies on other tables.
Your SQL should read like the following:

DELETE BatchID from yourtablename WHERE BatchID = 1
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Assuming you are manually entering the Batch ID

SELECT dbo_WorkTable1.*
FROM dbo_WorkTable1
WHERE dbo_WorkTable1.BatchID=[Enter Batch ID]
SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America 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
Avatar of Aravind Ranganathan

ASKER

@Tusitala  : i dont have any relationships on this table just want to delete it as the user passes the value into it.

My Query
PARAMETERS BatchID Int;
DELETE dbo_WorkTable1.*, dbo_WorkTable1.[Batch ID]
FROM dbo_WorkTable1
WHERE (((dbo_WorkTable1.[Batch ID])=[BatchID]));
@Jim Dettman (Microsoft MVP/ EE MVE)

User generated image
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
Again ...

Assuming you are manually entering the Batch ID

SELECT dbo_WorkTable1.*
FROM dbo_WorkTable1
WHERE dbo_WorkTable1.BatchID=[Enter Batch ID]
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
yes the same table is on sql server, the table does not have a primary key because it is not unique, each night i load a file into sql server and i assign a batch id for those files, so next day user opens the work table fixes the issue on the datasheet and runs an append query to move the data from work table to archive table. now i want the user to delete that data using the batch id. this is where i am stuck. can you please provide me with any work around.
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
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
Thanks Guys your answers really showed me how to trouble shoot an query.