autonumber problem

J

joyo

I have an autonumber field in a form as the record ID.
When use opens a blank form to add new record, some fields
fill by default values. such as record time. I also use
default value to display 'first name' and 'last name' in
name fields to remind users.

My question is, if user accidently opens the add new
record form, even though they don't intent to add a new
record, but the record id will be increased one.
How to solve this problem.

Thanks

joyo
 
R

Rick Brandt

joyo said:
I have an autonumber field in a form as the record ID.
When use opens a blank form to add new record, some fields
fill by default values. such as record time. I also use
default value to display 'first name' and 'last name' in
name fields to remind users.

My question is, if user accidently opens the add new
record form, even though they don't intent to add a new
record, but the record id will be increased one.
How to solve this problem.

The autonumber value should not be consumed simply by navigating to the new record
position (even if default values appear). If the user or your code *sets* any
values, then the record will be dirtied and the autonumber will be consumed. Is your
code setting any values on the form or are you just using the DefaultValue
properties?
 
D

Dirk Goldgar

joyo said:
I have an autonumber field in a form as the record ID.
When use opens a blank form to add new record, some fields
fill by default values. such as record time. I also use
default value to display 'first name' and 'last name' in
name fields to remind users.

My question is, if user accidently opens the add new
record form, even though they don't intent to add a new
record, but the record id will be increased one.
How to solve this problem.

If you use the controls' Default Value properties to set defaults for
the fields, just opening the form won't cause an autonumber to be
generated. But if you use code in the form's Open, Load, or Current
event to assign a value to a control as a default, then an autonumber
will be generated because you've dirtied the record. In that case,
there is nothing you can do about it.
 
H

Hugh O'Neill

joyo said:
I have an autonumber field in a form as the record ID.
When use opens a blank form to add new record, some fields
fill by default values. such as record time. I also use
default value to display 'first name' and 'last name' in
name fields to remind users.

My question is, if user accidently opens the add new
record form, even though they don't intent to add a new
record, but the record id will be increased one.
How to solve this problem.

Thanks

joyo


Further to what Rick and Dirk have said, it doesn't matter what values
Autonumber returns as they are of no interest to users or to developers.

Autonumber is designed only to provide a unique identifier for records
in a table. This is used internally by Access in building relationships
between tables according to your design. The actual values that
Autonumber delivers are unimportant and should never be exposed to
users or have any external meaning at all. Depending on the design and
use of the database, Autonumber will develop gaps, become
random and go negative.

For any number series that you want to control or have available
externally, you must design your own. There are several schemes
available depending on what you want to do.

hth

Hugh
 

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