why not try a simple solution ? Fetch the max(fieldname) from table.
something like :
Select max(Sno) from tblSomething;
Now this is the SNo of last record entered. Add one more to the value and you have next value.
P.S. - This is a bad practice doing something like this because in a scenario where "multiple users" are submitting the info, ambiguity will creep in.