Solved

Form Fields tied to Autonumber in tables, instant generation?

Posted on 1998-05-04
4
639 Views
Last Modified: 2012-06-27
With a relational database and referential integrity enforced, a form can reference data from more than one table.  If these tables have an Autonumber as primary key, it seems that as soon as one field from that table is entered on the form, an Autonumber generates.  Thus, if I want to clear the form, I have already used one of the numbers in sequence.  Is there a way to unbound the form or do I need to unbind each field individually?  Should I change the primary key to an integer and increment it by one myself with VBA?  Summarily, how can I make the form save the data only when I advance to the next screen or press a save button?
0
Comment
Question by:cyberwarrior
  • 2
  • 2
4 Comments
 

Author Comment

by:cyberwarrior
ID: 1960994
Edited text of question
0
 
LVL 27

Accepted Solution

by:
aburr earned 200 total points
ID: 1960995
The autonumber increments only when you add a record to a table. Thus when you request info FROM the table with a form the autonumber does not change. The form can be cleared with no change to the table.
-
An additional thought. Why do you use an autonumber. it is usually used when a unique key cannot be otherwise establised from the data in the record. is that the case with you? If it is not you do not need auto number.
0
 

Author Comment

by:cyberwarrior
ID: 1960996
This is a data entry form.  I am trying to develop this so that the user can change their mind and clear the data they have entered on the form.  The way it stands now, as soon as they enter the data corresponding to one of the tables, the autonumber is generated for that table.
0
 
LVL 27

Expert Comment

by:aburr
ID: 1960997
The autonumber is designed to provide a foolproof unique identifyer for a record, hence it is difficult to fool with it.

For a table that contains records, you can use this procedure to change the next value assigned in an AutoNumber field to a new number.

1      Create a temporary table with just one field, a Number field; set its FieldSize property to Long Integer and give it the same name as the AutoNumber field in the table whose value you want to change.

How?

2      In Datasheet view, enter a value in the Number field of the temporary table that is 1 less than the starting value you want for the AutoNumber field. For example, if you want the AutoNumber field to start at 100, enter 99 in the Number field.
3      Create and run an append query to append the temporary table to the table whose AutoNumber value you want to change.

How?

Note   If your original table has a primary key, you must temporarily remove the primary key before running the append query. Also, if your original table contains fields that have the Required property set to Yes, the Indexed property set to Yes (No Duplicates), or field and/or record ValidationRule property settings that prevent Null entries in fields, you must temporarily disable these settings.

4      Delete the temporary table.
5      Delete the record added by the append query.
6      If you had to disable property settings in step 3, return them to their original settings.

When you enter a record in the remaining table, Microsoft Access uses an AutoNumber field value 1 greater than the value you entered in the temporary table.

Another possibility is to have your form dump its data into an append querry. when the data is satisfactory to the inputter then append the records.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question