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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

min value in update query 1

Status
Not open for further replies.

patrichek

MIS
Nov 18, 2003
632
US
Hi,
in a previous post i prepared (with help)a query for an update query. Here is the original query code before the update:

SELECT Calls.ContactID, Min(Calls.CallDate) AS [date], Contacts.Source
FROM Contacts INNER JOIN Calls ON Contacts.ContactID = Calls.ContactID
WHERE Contacts.Source = 'website'
GROUP BY [Calls.ContactID], Contacts.Source;

When i click update query from the query builder menu, the group by min disappears and does not function when i run the update. How would i make this work using the min?

Here's my update query code:

UPDATE Contacts INNER JOIN Calls ON Contacts.ContactID = Calls.ContactID SET Contacts.[Date received] = [calls].[calldate]
WHERE (((Contacts.Source)='website'));


thanks!
 
You may try this:
UPDATE Contacts
SET [Date received] = (SELECT Min(CallDate) FROM Calls WHERE ContactID = Contacts.ContactID)
WHERE Contacts.Source = 'website'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,
thanks for the response but i get "must use an updateable query" error?
 
And this ?
UPDATE Contacts
SET [Date received] = DMin('CallDate', 'Calls' ,'ContactID=' & Contacts.ContactID)
WHERE Contacts.Source = 'website'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top