?
Solved

Access SQL autonumber update problem

Posted on 2011-09-20
7
Medium Priority
?
360 Views
Last Modified: 2012-06-21
I have a SQL 2000 database with an autonumber as the key field (intNewIntkey), I restored the database to a test system and ran this code: -
    Do Until rst.BOF Or rst.EOF = True
        With rsItem
            .AddNew
            ![ContractNumber] = rst!ContractNumber
            ![Description] = rst!Description
            .update
            .Bookmark = .LastModified
            intNewIntkey = ![InternalKeyNumber]
        End With

I ran this on the test and imported 300 items no problem, on the live it fails as the InternalKeyNumber is null (error 3022), can anyone help?
0
Comment
Question by:HKFuey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 36565905
Double check the column Identity Specification property for InternalKeyNumber in your SQL back end.

Is Identity should be set to YES.
0
 
LVL 9

Expert Comment

by:sachinpatil10d
ID: 36566330
0
 

Author Comment

by:HKFuey
ID: 36567406
Hi mbizup,
Identity is set to yes. I did a restore anyway as I suspected corruption. Users only lost 3/4 hours work.
0
Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

 
LVL 42

Accepted Solution

by:
dqmq earned 2000 total points
ID: 36567713
Assuming your identity is incrementing, do this from the SQL prompt:

SELECT MAX([InternalKeyNumber]) FROM yourtable

DBCC CHECKIDENT ('yourtable', RESEED, #######)


For ###### substitute the number returned from the first select.
0
 

Author Comment

by:HKFuey
ID: 36567732
Hi dqmg,
The internal key number links to other tables, will this break the link?
0
 
LVL 42

Expert Comment

by:dqmq
ID: 36568037
It doesn't update existing rows... just affects rows that are subsequently added.  If the rows being inserted are linked to other tables, then you have a serious matter.
0
 

Author Closing Comment

by:HKFuey
ID: 36569660
Thanks dqmq, I got it to work, but I also changed my data so not sure what did it!!
Happy anyway : )
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

764 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