Why not use the autonumber value as the unique id? It is guaranteed to be unique.
Also, the value of the most recent autonumber is not a good way to determine the number of records in a table. If you delete any records, the autonumber will be greater than the number of records.
Did you setup the input variable in the left panel of the editor?