Form data entry

S

Sandy

Is it possible to have a command button included on a form, that when
clicked the current entry being entered is aborted, without the autonumber
field being tripped to the next number.

eg data entry started and autonumber field shows 7 - data entry aborted -
nothing saved - next new entry shows 8 even although entry 7 does not exist.

Thanks
Sandy
 
S

S Panja

It is possible if the form is not based on the table. The form can have the
required fields [except autonumber]. You may use the command button to append
the record.
--
********* http://panjas.org
If the message was helpful to you, click Yes next to Was this post helpful
to you?
If the post answers your question, click Yes next to Did this post answer
the question?
 
R

Rick Brandt

Sandy said:
Is it possible to have a command button included on a form, that when
clicked the current entry being entered is aborted, without the
autonumber field being tripped to the next number.
No

eg data entry started and autonumber field shows 7 - data entry
aborted - nothing saved - next new entry shows 8 even although entry
7 does not exist.

Any time you care about the value in any way other than it being unique DON'T
use an AutoNumber.

There are many completely normal operations that will produce gaps in AutoNumber
sequences. For example, if you run an APPEND query but cancel it at the prompt
"You are about to insert 5000 row(s)... Are you sure you want to append the
selected rows?", you will still consume 5000 AutoNumber positions.

If you require a gapless, incrementing sequence of numbers then you need to
assign the numbers your self, either manually or with code. A common method is
to use code in the BeforeUpdate event.

If Me.NewRecord Then
Me!IDField = Nz(DMax("IDField", "TableName"),0) + 1
End If

This would still allow for gaps if records are deleted, but it eliminates the
gaps caused by what you are seeing.
 
S

Sandy

Thank you Rick
Very useful.
Sandy

Rick Brandt said:
Any time you care about the value in any way other than it being unique
DON'T use an AutoNumber.

There are many completely normal operations that will produce gaps in
AutoNumber sequences. For example, if you run an APPEND query but cancel
it at the prompt "You are about to insert 5000 row(s)... Are you sure you
want to append the selected rows?", you will still consume 5000 AutoNumber
positions.

If you require a gapless, incrementing sequence of numbers then you need
to assign the numbers your self, either manually or with code. A common
method is to use code in the BeforeUpdate event.

If Me.NewRecord Then
Me!IDField = Nz(DMax("IDField", "TableName"),0) + 1
End If

This would still allow for gaps if records are deleted, but it eliminates
the gaps caused by what you are seeing.
 

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