Solved

Form Fields tied to Autonumber in tables, instant generation?

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can not open the Access Help ? 3 53
Attachment field in SQL 3 28
How to use DLookup with IsNull Function 4 26
Batch Export Reports (with multiple parameters) As PDF 2 21
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

770 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