[AccessD] Membership File Changes

Gustav Brock gustav at cactus.dk
Fri Mar 7 12:08:31 CST 2014


Hi Bill

No need to delete the record. Just run this twice:

CurrentDb.Execute "insert into A (Field2) Values ('new');"

/gustav

________________________________________
Fra: accessd-bounces at databaseadvisors.com <accessd-bounces at databaseadvisors.com> på vegne af Bill Benson <bensonforums at gmail.com>
Sendt: 7. marts 2014 18:02
Til: 'Access Developers discussion and problem solving'
Emne: Re: [AccessD] Membership File Changes

OK, this discussion has intrigued me like few others. I have found a fun and
free way to corrupt my database. Play along boys and girls and I am sure it
will be fun for you too. In the below example, B is used as a temp table to
hold a couple of values for the fun and exciting purpose of destroying A's
usefulness.

CurrentDb.Execute "DROP TABLE [A];"
CurrentDb.Execute "DROP TABLE [B];"
CurrentDb.Execute "CREATE TABLE [A] (ID AUTOINCREMENT NOT NULL PRIMARY KEY,
Field2 TEXT);"
CurrentDb.Execute "CREATE TABLE [B] (ID LONG, Field2 TEXT);"
CurrentDb.Execute "INSERT INTO B (ID, FIELD2) VALUES (-2147483648,
'DELETEME');"
CurrentDb.Execute "INSERT INTO B (ID, FIELD2) VALUES (2147483647,
'DELETEME');"
CurrentDb.Execute "INSERT INTO A SELECT * FROM B;"
CurrentDb.Execute "DELETE FROM [A] WHERE ID =2147483647;"
CurrentDb.Execute "DROP TABLE [B];"

This leaves a single record in table A with ID = -2147483648

Now try and add a new record to A and you will find you cannot. Why doesn't
it autoincrement to -2147483647 ? That is a very good question. Let's now
delete the one record remaining and try again:

          CurrentDb.Execute "DELETE FROM [A] WHERE ID =2147483648;"

Or alternatively
          CurrentDb.Execute "DELETE * FROM [A];"

Now add a new record and you will see that the database begins a new record
at ID = -2147483647!!!!

DEFIES ALL LOGIC! It has been my pleasure to baffle you!


More information about the AccessD mailing list