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

Update Query Problem 1

Status
Not open for further replies.

papic1972

Technical User
Apr 10, 2003
209
AU
Hi all,

I have the following code in a select query:

SELECT qryJobswithNoDeliveriesintheLast3months.JobNo, Max(qryJobswithNoDeliveriesintheLast3months.ActualDate) AS MaxOfActualDate, tblJob.JobId, tblJob.Customer, tblJob.ContactName, tblJob.ContactNo1, tblJob.StreetAddress, tblJob.Suburb, tblJob.CompletedJob
FROM tblJob RIGHT JOIN qryJobswithNoDeliveriesintheLast3months ON tblJob.JobId = qryJobswithNoDeliveriesintheLast3months.JobNo
GROUP BY qryJobswithNoDeliveriesintheLast3months.JobNo, tblJob.JobId, tblJob.Customer, tblJob.ContactName, tblJob.ContactNo1, tblJob.StreetAddress, tblJob.Suburb, tblJob.CompletedJob
HAVING (((Max(qryJobswithNoDeliveriesintheLast3months.ActualDate))<#6/30/2004#) AND ((tblJob.CompletedJob)=False));


I need to update the yes/no field "Completed Job" from "False" to "True" based on the criteria in the code. I have tried converting this query to an update query but it does not work properly. Am I doing this the correct way or is there some other way to approach this. Any help would be of benefit.

Thanks in advance.
 
Something like this ?
UPDATE tblJob SET CompletedJob=True
WHERE JobId In (SELECT DISTINCT JobNo FROM [query name of your posted SQL])

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
hmmmm.....

I tried creating a new qry using your code PHV & 20 minutes later the qry was still running!!!!!

No luck with that one!
 
So, try a maketable first based on your posted query creating a temporary table named, say, tmpJobtbl and then:
UPDATE tblJob INNER JOIN tmpJobtbl ON tblJob.JobId = tmpJobtbl.JobNo
SET CompletedJob = True

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Beautiful!!!!

That worked!

That deserves a star, how do I give you one?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top