I made the following query for SQL Server backend
SELECT TOP(1) (v.rownum + 99) FROM ( SELECT incrementNo-99 as id, ROW_NUMBER() OVER (ORDER BY incrementNo) as rownum FROM proposals WHERE [year] = '12' ) as v WHERE v.rownum <> v.id ORDER BY v.rownum
to find the first unused offer number. (This is not about the last post +1)
But I realized that ROW_NUMBER not supported in access. I looked and I can not find something like that.
Does anyone know how to get the same result as ROW_NUMBER on access?
Maybe there is a better way to do this.
Actually, people insert their sentence No (incrementID) without restrictions. This number is similar to 13-152. xx- for the current year, and -xxx - offer number. The last 3 digits must be incremental, but in some cases, maybe 10 times a year they have to skip some digits. Therefore, I cannot have auto-increment.
So, I make this request, so when they open the form, the default number is the first unused .
How it works:
Since the number starts at 100, I do -99, so it starts at 1.
Then I compare the line number with the identifier so that it looks like this:
ROW NUMBER | ID 1 1 (100) 2 2 (101) 3 3 (102) 4 5 (104)<--------- WRONG 5 6 (105)
So, now I know that we are missing 4. So I'm coming back (4 - 99) = 103
If there is a better way, I am not against change, but I really like this request.
If there is no other way, and I can not simulate the line number in the access, I will use the pass through the request.
thanks