using last record as upate parameter

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];
 
K

Ken Sheridan

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
 
Top