Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Query Help

Status
Not open for further replies.

ptrifile

Technical User
Aug 10, 2004
457
US
Looking for some help. I have a delete query that does not appear to be working. I have two tables (tblCurrentTimeOff and tblEmployee). When the query runs, if tblCurrentTimeOff.EmployeeNumber matches an EmployeeNumber in tblemployee I would like to delete that record in tblEmployee.

I thought this was working before but it appears not to be. Here is the SQL that I am using:

Code:
DELETE DISTINCTROW tblemployee.*
FROM tblemployee INNER JOIN tblCurrentTimeOffTuesday ON tblemployee.EmployeeNumber = tblCurrentTimeOffTuesday.EmployeeNumber;

Can anyone help me get this working? Much appreciated!

Paul
 
Thanks for the quick response dhookom. When I remove DISTINCTROW i get an error "could not delete from specified tables". I think i have an issue somewhere else as it appears as if sometimes it works and sometimes it doesn't. I need to try and nail down whats happening in both circumstances. Thanks for the help.
 
I don't understand the logic of deleting an employee record however, you might try:

SQL:
DELETE tblemployee.*
FROM tblemployee 
WHERE EmployeeNumber IN (SELECT EmployeeNumber FROM tblCurrentTimeOffTuesday);

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top