Select NVL(max(itemnum), 0) from inspdata where jobnum==lnJobnum into array lnMaxItem RETURN lnMaxItem[1]Also if table/view is buffered it'll require
WITH (BUFFERING = .T.)>It may not be related, but instead of Calculate, I would use a SQL Select statement instead, since it doesn't move the record pointer.
>IF !EOF('inspdata') AND !BOF('inspdata') > local lnjobnum > lnJobnum=inspheader.jobnum > Select max(itemnum) from inspdata where jobnum==lnJobnum into array lnMaxItem > RETURN lnMaxItem >ELSE > Return 0 >endif>