C
Clddleopard
I have the following query:
UPDATE EnrichmentAssignments INNER JOIN Query6 ON
(EnrichmentAssignments.[Enrichment Type] = Query6.[Enrichment Type]) AND
(EnrichmentAssignments.[Animal Name] = Query6.[Animal Name]) SET
EnrichmentAssignments.[Enrichment Type] = "Toy"
WHERE (((Query6.MinOfAssignmentID) Is Null)) OR
(((EnrichmentAssignments.AssignmentID)<>[MinOfAssignmentID] And
(EnrichmentAssignments.AssignmentID)<>[MaxOfAssignmentID]));
Query6 has the following SQL:
SELECT [Find duplicates for EnrichmentAssignments].[Animal Name Field],
EnrichmentAssignments.[Animal Name], EnrichmentAssignments.[Enrichment Type],
Max(EnrichmentAssignments.AssignmentID) AS MaxOfAssignmentID,
Min(EnrichmentAssignments.AssignmentID) AS MinOfAssignmentID
FROM EnrichmentAssignments INNER JOIN [Find duplicates for
EnrichmentAssignments] ON EnrichmentAssignments.[Animal Name]=[Find
duplicates for EnrichmentAssignments].[Animal Name Field]
GROUP BY [Find duplicates for EnrichmentAssignments].[Animal Name Field],
EnrichmentAssignments.[Animal Name], EnrichmentAssignments.[Enrichment Type]
HAVING ((Not ([Find duplicates for EnrichmentAssignments].[Animal Name
Field]) Is Null) AND ((EnrichmentAssignments.[Enrichment Type]) Like
"enviro*"));
The first sql won't update (it says Operation must use an updateable query).
What I have is a table with the fields Enrichment Type, Animal Name, Give
Date, and Assignment ID. If an Animal Name has five records with Enrichment
Type "enviro", I want to change all but two of them to "toy". Or, if an
Animal Name has 6 records with Enrichment Type "enviro", I want to change 4
of them (all but two) to toy.That's what my sql is trying to do. The top
query selects exactly what I want (when it is a select query), but then it
won't let me update. I am not writing sql, I'm using the design query grid in
Access. If anyone can tell me what to change in the sql I've got or has a
better way of doing what I want, I'd be very grateful.
UPDATE EnrichmentAssignments INNER JOIN Query6 ON
(EnrichmentAssignments.[Enrichment Type] = Query6.[Enrichment Type]) AND
(EnrichmentAssignments.[Animal Name] = Query6.[Animal Name]) SET
EnrichmentAssignments.[Enrichment Type] = "Toy"
WHERE (((Query6.MinOfAssignmentID) Is Null)) OR
(((EnrichmentAssignments.AssignmentID)<>[MinOfAssignmentID] And
(EnrichmentAssignments.AssignmentID)<>[MaxOfAssignmentID]));
Query6 has the following SQL:
SELECT [Find duplicates for EnrichmentAssignments].[Animal Name Field],
EnrichmentAssignments.[Animal Name], EnrichmentAssignments.[Enrichment Type],
Max(EnrichmentAssignments.AssignmentID) AS MaxOfAssignmentID,
Min(EnrichmentAssignments.AssignmentID) AS MinOfAssignmentID
FROM EnrichmentAssignments INNER JOIN [Find duplicates for
EnrichmentAssignments] ON EnrichmentAssignments.[Animal Name]=[Find
duplicates for EnrichmentAssignments].[Animal Name Field]
GROUP BY [Find duplicates for EnrichmentAssignments].[Animal Name Field],
EnrichmentAssignments.[Animal Name], EnrichmentAssignments.[Enrichment Type]
HAVING ((Not ([Find duplicates for EnrichmentAssignments].[Animal Name
Field]) Is Null) AND ((EnrichmentAssignments.[Enrichment Type]) Like
"enviro*"));
The first sql won't update (it says Operation must use an updateable query).
What I have is a table with the fields Enrichment Type, Animal Name, Give
Date, and Assignment ID. If an Animal Name has five records with Enrichment
Type "enviro", I want to change all but two of them to "toy". Or, if an
Animal Name has 6 records with Enrichment Type "enviro", I want to change 4
of them (all but two) to toy.That's what my sql is trying to do. The top
query selects exactly what I want (when it is a select query), but then it
won't let me update. I am not writing sql, I'm using the design query grid in
Access. If anyone can tell me what to change in the sql I've got or has a
better way of doing what I want, I'd be very grateful.