Solved

copy back a table with autonumber

Posted on 2014-04-19
6
383 Views
Last Modified: 2014-04-19
Dear Experts,

I have a table with autonumber as index, but I allow the user to delete records randomly.
After that, I want to restore the table with autonumber without skipping, so I thought I could export the table without the autonumber field, then insert it back to the original structure.  As I am trying to do that, I get "invalid argument" error, and does not work.
How can I get my table to refresh, and get the autonumber in order as if I am entering the data as new?
Please advise.
0
Comment
Question by:yballan
  • 3
  • 2
6 Comments
 
LVL 29

Expert Comment

by:IrogSinta
ID: 40010834
What is your purpose in re-sequencing the autonumber field?  That would be very inefficient to do every time a record is deleted.

Ron
0
 

Author Comment

by:yballan
ID: 40010840
More information:
In attempt to troubleshoot my query, I trimmed it down to just inserting one field, then I got a different error, looking for a mdb file.
But I am using Access 2010, my files are called XXX.accdb, and it is stored in a totally different folder from what the error message says.
I am extremely puzzled, please advise.
Untitled.jpg
0
 

Author Comment

by:yballan
ID: 40010843
Dear IrogSinta,

Thank you for your quick reply, I use the index for traversing forward and backward, and I find it easier to link everything if autonumbered index is in order.
This is meant to be as refreshing the table, and not supposed to happen often.
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 250 total points
ID: 40010851
I'm with IrogSinta,

Autonumber fields are meant to be used as primary keys and should be irrelevant to users as they should never even be visible to users.  

Indexing and traversing forward and backwards through the recordset has nothing to do with skipped values in the autonumber field.

Linking to that table will be a nightmare if you allow changes to the autonumber field and will likely break references to other tables.

I never resequence an autonumber field except when I first deploy an application, and then only after deleting all of the records in the table that were created during development and testing.  And only then for tables which are not used as lookup tables for use in my combo boxes and such.
0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 250 total points
ID: 40010878
I will answer you're question on the problem with your Insert SQL statement question; however, this is just for your learning benefit and does not mean that you should continue down this erroneous path.  Fyed already gave you an excellent explanation on why you should not take that route.  It can definitely cause future problems.  Perhaps you should show us how you traverse your recordsets; you may be doing it wrong.

Here's the correction to your SQL:
INSERT INTO New Products (CategoryS) SELECT CategoryS FROM RefreshNewProduct

Open in new window

0
 

Author Closing Comment

by:yballan
ID: 40010886
Dear feyd and IrogSinta,

I appreciate your educating me for this error, I do realize that I am trying to force something that is not quite right.  I have inherited this large amount of code, and since I am short of time, I did not want to rewrite all of the traversing codes.  I understand that there is something fundamentally flawed with the design of the original code, and what I really should do is to understand it, and correct it.

Once I get through this deadline, I will rewrite this, I do believe that it will cause other problems as you said.
Thank you for the correct SQL script.
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

Suggested Solutions

Title # Comments Views Activity
VB6 - Scroll Mouse wheel on Picturebox 13 44
Dcount using a date in a table compared to today's date 3 31
DCount Type Mismatch 2 22
combo box query 6 8
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

831 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