using last record as upate parameter

  • Thread starter Thread starter cporter
  • Start date Start date
C

cporter

I've designed and run a query that finds the last workorder number in
my table. I'm trying to take that value into an update query and use it
to generate some new numbers. When I run the query a dialog box comes
up and asks for the value of [WORKORD Query]![LastOfWONO]. Is there
some special reason the value in the first query isn't automatically
passed on? What do I need to do to get it to pass this value through?




WORKORD Query

SELECT Last(WORKORD.WONO) AS LastOfWONO
FROM WORKORD;


qryPMWOcalc

UPDATE tblPMWO SET tblPMWO.wono = [WORKORD Query]![LastOfWONO]+[ID];
 
Normally I'd suggest a subquery in this sort of situation, but if you use a
subquery which contains any SQL aggregate function the outer query won't be
updatable. Instead, therefore, use the VBA DMax function (I assume the
'last' value means the highest).

UPDATE tblPMWO
SET wono = DMax("wono","WorkOrd") + ID;

Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top