Delete Query... SQL not working (1 Viewer)

mumbles10

Registered User.
Local time
Today, 09:02
Joined
Feb 18, 2011
Messages
66
I know this is wrong... but I am trying to write a DELETE Query in SQL based on certain parameters... Thanks.

DELETE tblEmployeeAccess.EmployeeID, tblEmployeeAccess.SystemID, tblEmployeeAccess.EntitlementID
FROM tblEmployeeAccess
WHERE (((tblEmployeeAccess.EmployeeID)

=(SELECT tblEmployees.EmployeeID
FROM (tblEmployees INNER JOIN (tblEmployeeAccess ON tblEmployees.EmployeeID = tblEmployeeAccess.EmployeeID) INNER JOIN tblSystems ON tblSystems.SystemID = tblEmployeeAccess.SystemID) INNER JOIN tblEntSample ON tblEmployeeAccess.EntitlementID = tblEntSample.EntitlementID)

WHERE (((tblEntSample.EntitlementName)=[Forms]![frmChoice]![lboEntitlements]) AND ((tblSystems.SystemID) = [Forms]![frmChoice]![cboChoiceSys]) AND ((tblEmployees.EmployeeID) = [Forms]![frmChoice]![cboChoiceName])))) AND
((tblEmployeeAccess.SystemID)

= (SELECT tblSystems.SystemID
FROM (tblEmployees INNER JOIN (tblEmployeeAccess INNER JOIN (tblSystems ON tblEmployeeAccess.SystemID = tblSystems.SystemID) INNER JOIN tblEntSample ON tblEmployeeAccess.EntitlementID = tblEntSample.EntitlementID

WHERE (((tblEntSample.EntitlementName)=[Forms]![frmChoice]![lboEntitlements]) AND ((tblSystems.SystemID) = [Forms]![frmChoice]![cboChoiceSys]))) AND ((tblEmployees.EmployeeID) = [Forms]![frmChoice]![cboChoiceName]))) AND ((tblEmployeeAccess.EntitlementID

= (SELECT tblEntSample.EntitlementID
FROM (tblEmployees INNER JOIN (tblEmployeeAccess INNER JOIN (tblSystems INNER JOIN (tblEntSample ON tblEmployeeAccess.EntitlementID = tblEntSample.EntitlementID) ON tblSystems.SystemID = tblEmployeeAccess.SystemID) ON tblEmployees.EmployeeID = tblEmployeeAccess.EmployeeID

WHERE (((tblEntSample.EntitlementName)=[Forms]![frmChoice]![lboEntitlements]) AND ((tblSystems.SystemID) = [Forms]![frmChoice]![cboChoiceSys]))) AND ((tblEmployees.EmployeeID) = [Forms]![frmChoice]![cboChoiceName])));
 

Trevor G

Registered User.
Local time
Today, 13:02
Joined
Oct 1, 2009
Messages
2,341
look to create a query as normal and then select the delete query once you have done this you can view the SQL code and copy that and enchance it to use VBA with SQL to run the delete query.
 

mumbles10

Registered User.
Local time
Today, 09:02
Joined
Feb 18, 2011
Messages
66
look to create a query as normal and then select the delete query once you have done this you can view the SQL code and copy that and enchance it to use VBA with SQL to run the delete query.


That is what I tried initially but it didn't work.
 

Users who are viewing this thread

Top Bottom