Solved

Form Fields tied to Autonumber in tables, instant generation?

Posted on 1998-05-04
4
604 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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now