I believe, you are going wrong while trying to take the maximum value in the variable.
It is not possible to get the max() of a field in variable by the way you are trying to follow.
1st try to load your Entryno table and order the same table by Entryno ascending order.
then use peek function to take the maximum value, then use that variable in select query.
Hope that should work.
Check my attachment to take max value in to variable.
from test order by Entry_Num ASC;
LET var1 = peek('Entry_Num', -1, Test1);
I hope this should help you.
test.qvw 112.2 K