hhmr17
02-23-2008, 10:55 AM
Hey,
Basically my goal is to have records in my customer table deleted from a date in my Service Allocations table. They are related by the Customer ID that is contained in both tables.
Customer Table:
Customer ID
field 1
field 2
field 3
field 4
so on
Service Allocations:
S-Allocation ID
Dte
Customer ID
Mechanic ID
Automobile ID
Service ID
So where the date is more than 5 years old from the current date (I'm using <=DateAdd("yyyy",-5,Date()) to do this), I want this query to delete the related customer records. How can I go about doing this as I keep getting the "Could not delete from specified tables" error. The actual code works in datasheet view, but somehow when I run the delete query it doesn't work.
The SQL for my query is:
DELETE [Service Allocations].Dte, Customer.*
FROM Customer INNER JOIN [Service Allocations] ON Customer.[Customer ID] = [Service Allocations].[Customer ID]
WHERE ((([Service Allocations].Dte)<=DateAdd("yyyy",-5,Date())));
Thanks for reading!
---------
Hamid
Basically my goal is to have records in my customer table deleted from a date in my Service Allocations table. They are related by the Customer ID that is contained in both tables.
Customer Table:
Customer ID
field 1
field 2
field 3
field 4
so on
Service Allocations:
S-Allocation ID
Dte
Customer ID
Mechanic ID
Automobile ID
Service ID
So where the date is more than 5 years old from the current date (I'm using <=DateAdd("yyyy",-5,Date()) to do this), I want this query to delete the related customer records. How can I go about doing this as I keep getting the "Could not delete from specified tables" error. The actual code works in datasheet view, but somehow when I run the delete query it doesn't work.
The SQL for my query is:
DELETE [Service Allocations].Dte, Customer.*
FROM Customer INNER JOIN [Service Allocations] ON Customer.[Customer ID] = [Service Allocations].[Customer ID]
WHERE ((([Service Allocations].Dte)<=DateAdd("yyyy",-5,Date())));
Thanks for reading!
---------
Hamid