You can't manipulate Autonumbers! It assigns a new number (either sequential
or random depending on what you set). Furthermore, it uses an Autonumber on
"New Record" whether you save the record or not.
Use a numeric field (or a text field manipulated via numerics) if you want to
add 1 to YOUR OWN field.
Your code is poor too. You don't have to step through a recordset to get the
existing max value. Lookup MAX in Query help!(you can do the same thing with a
single query)
So far as I know, getting/setting the next record number should be done in
Before Update event. Because, a new number is not necessary unless the record
is actually saved! (and may limit some multi-user conflicts for the same
reason)
(It is sometimes said that Autonumbers are only for internal database use.
Whatever, certainly you can't guarantee what they are! And most certainly you
can't set them)
Chris
PS It is considered good ACCESS practice, due to BUGS since Access97, to close
a recordset, and possibly to Set rst = Nothing also. Otherwise you can get
leftover "funnies", either memory leaks or Access not quitting (I've forgotten
exactly). It sucks if MS never fixed these bugs, but there you nearly caught
me ranting :-)
"Rino" <davorins@gmail.com> wrote in message
news:1155277758.361582.191470@p79g2000cwp.googlegroups.com...
|