I'm developing a vb.net program that inserts records on a MSAccess table. The structure of the record is very simple: Field a1 is a counter Field b1 is a a numeric value As you know when I insert a record I do not have to specify the counter value (a1 field) because it is calculated automatically. Generally the next value is incrementebd by 1 but, if the last inserted record is deleted, the counter value is calculated by adding the last counter value +2. My program should show the counter value of the record before insert it in the table. How to calculate it ? Thank you very much for your help and cooperation regards
Asked
Active
Viewed 48 times
0
-
7_My program should show the counter_ No, you shouldn't use those values for your UI – Steve Oct 07 '15 at 21:09
-
1The auto increment ID is just a unique identifier. It is of no interest to the user at all – user3697824 Oct 07 '15 at 22:48
-
2"...if the last inserted record is deleted, the counter value is calculated by adding the last counter value +2". No it isn't. The system knows what the last generated value was and it increments that. Why exactly do you think you need to display this value before saving? There can be legitimate reasons but usually people who want to do that are simply misguided and haven't considered all the implications or alternatives. – jmcilhinney Oct 08 '15 at 01:41
-
VB6 answer, but you should be able to adapt it. http://stackoverflow.com/questions/6498221/retreve-next-autonumber-for-access-table – jac Oct 08 '15 at 02:59