Autonumber in add mode

B

Bobbye R

I have a form the allows the user to select a option button to either add
records or search/edit a record once the form is open. My problem is when I
want to add a new record. The New records have an autonumber. On my old add
form the autonumber didn't appear unless I started to enter data on the form
but what's happening now is when I use the option button for a new record the
autonumber is already on the form. How can I make it go away short of using
the undo since the undo increments my autonumber?
 
L

Linq Adams via AccessMonster.com

I guess we need to see the code that opens the form in AddMode. Do any of the
controls on the form have default values? Do any of them have expressions as
their ControlSource?

The other thing is that if you're concerned about your Autonumber being
incremented if you use Undo, you're probably using the Autonumber field for
something that you shouldn't be using it for! As John Vinson would say (and
he may very well show up here and explain in more depth) autonumbers aren't
fit for human consumption! They're really intended to be used by Access for
"housekeeping" chores and should always stay in the background. If you need a
serial/identification/record number you need to implement your own auto-
incrementing number scheme.
 
L

Linq Adams via AccessMonster.com

I'll give John's fingers a break! Here a previous post by him:

From John W. Vinson, MVP:

“When using Autonumber, do be aware that there will be gaps in
the numbering - any record that's deleted will leave a gap; hitting
<Esc> after starting a record will leave a gap; adding records using an
Append query may leave a gap, often a huge one; replicating the database will
make your invoice numbers random.

In short... it's best NOT to use Autonumbers for human consumption, and
particularly not for consumption by accountants and auditors. Invoice
sequences like 319, 321, 322, 385, 386, 221841246, -1083225152 make such
people get very nervous.â€
 
M

Marshall Barton

Bobbye said:
I have a form the allows the user to select a option button to either add
records or search/edit a record once the form is open. My problem is when I
want to add a new record. The New records have an autonumber. On my old add
form the autonumber didn't appear unless I started to enter data on the form
but what's happening now is when I use the option button for a new record the
autonumber is already on the form. How can I make it go away short of using
the undo since the undo increments my autonumber?


What you want is the normal behavior, which implies that you
have some code that is setting the value of a field (or
bound control). I would guess the code would be in the
button's Click event or in the form's Current event.
 
B

Bobbye R

Thanks Marshall. That was the problem. I had moved a validation statement
in the forms on current event. I spent hours....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top