INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

In my code, I create and fill a tab

In my code, I create and fill a tab

(OP)
In my code, I create and fill a table that typically has about 100,000 records. The first field, ID, is an autonumber field.
Later in my code, I copy this table to other MDB programs. Doing this causes the ID numbers to keep incrementing, but I want each copy to be IDENTICAL. So, I try to change the Data Type from Autonumber to Long with DDL code like...

CODE -->

db.Execute "ALTER TABLE " & strTblName & " ALTER COLUMN [ID] LONG" 

Usually this works perfectly, but when the table occasionaly has about 600,000 records, I get an error message re Lack of System Resources.
Even if i manually open the table in Design View and try to change the ID field from Autonumber to Number (Long), I get the error message "There isn't enough disk space of memory."

Here's the question - how can I use VBA or DDL to modify a field's data type from Autonumber to Long WHEN THE TABLE IS LARGE?

Thanks
teach314

RE: In my code, I create and fill a tab

(OP)
ok - I found an answer to the problem.

a) in the table, I called the Autonumber field [ID_TEMP], and included an EMPTY (LONG)field [ID].

Once the table was filled, I used DDL to...

b) COPY the values from [ID_TEMP] to [ID]....

c) DROP the PRIMARY KEY constraint from [ID_TEMP]...

d) DROP the Autonumber field [ID_TEMP]...

e) ADD PRIMARY KEY to Long field [ID].

This works perfectly with very large tables unlike the earlier method.

teach314

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close