General discussion

Locked

Access: Control Autonumber Update?

By dk_walton ·
I have a record creation form connected to a table in the usual Access way.

As expected, as soon as any field in the form has data entered in it a form dirty event occurs and the Autonumber primary key is automatically created for the new record.

Once the new Autonumber is created, there is no "going back". If the form data is discarded, the Autonumber assigned is no longer available for use in the table.

I would like to control when the Autonumber field is updated so that a new Autonumber is generated if and only if an explicit save of the form data is executed by the user.

It looks as though the only way to achieve this is to use an unbound form and fields and DAO or ADO methods in VBA.

Any other ideas on how to interrupt the automatic assignation of Autonumbers (on a bound form)?

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Access: Control Autonumber Update?

by Bob Sellman In reply to Access: Control Autonumbe ...

For the addition of new records, try using a separate copy of the table that has all columns except the autonumber column. This table could be part of your application front end. The add records form would use this table as the record source. Thefollowing actions would occur:

1. User adds new record information.
2. User clicks on "Save record" button (or whatever you have) and these happen:
a. The record is added to the "real" table. (Which will automatically number the record)
b. The record is deleted from the add record table (which should never have more than one record).
3. If use voids the record rather than saving it, it just gets deleted from the add record table.

Collapse -

Access: Control Autonumber Update?

by dk_walton In reply to Access: Control Autonumbe ...

Thanks Bob. I was hoping this question might generate more response, but my own further study seems to indicate that there are not many solutions. Yours is a creative and useful answer, and one I did not (and probably would not) have thoughtof. Thanks again.

Collapse -

Access: Control Autonumber Update?

by dk_walton In reply to Access: Control Autonumbe ...

This question was closed by the author

Back to Software Forum
3 total posts (Page 1 of 1)  

Related Forums