PC Review


Reply
Thread Tools Rate Thread

How to clear records from a database

 
 
=?Utf-8?B?bmlra2k=?=
Guest
Posts: n/a
 
      31st Jan 2006
I have been entering "fake" data into my database while creating it and now I
am ready to enter the real data, but need to get rid of the old records. I
know I can simply delete selected records, but whenever I do that, there is
always a gap in the record ID numbers and the count if off. How do I
completely clear out records from a database to make it as if they were never
there. Anyone with experience on this, I would love the help!
 
Reply With Quote
 
 
 
 
=?Utf-8?B?S0FSTCBERVdFWQ==?=
Guest
Posts: n/a
 
      31st Jan 2006
Try compacting after deleting. Close and reopen.

"nikki" wrote:

> I have been entering "fake" data into my database while creating it and now I
> am ready to enter the real data, but need to get rid of the old records. I
> know I can simply delete selected records, but whenever I do that, there is
> always a gap in the record ID numbers and the count if off. How do I
> completely clear out records from a database to make it as if they were never
> there. Anyone with experience on this, I would love the help!

 
Reply With Quote
 
John Vinson
Guest
Posts: n/a
 
      31st Jan 2006
On Tue, 31 Jan 2006 12:58:27 -0800, "nikki"
<(E-Mail Removed)> wrote:

>I have been entering "fake" data into my database while creating it and now I
>am ready to enter the real data, but need to get rid of the old records. I
>know I can simply delete selected records, but whenever I do that, there is
>always a gap in the record ID numbers and the count if off. How do I
>completely clear out records from a database to make it as if they were never
>there. Anyone with experience on this, I would love the help!


A Delete query

DELETE * FROM tablename;

will delete all records (if you have relational integrity enforced,
you'll need to run these delete queries in the right order, "many"
side tables first).

Autonumbers ARE NOT counts, and ARE NOT suitable for "record ID
numbers' which will be seen by people. An autonumber will *always*
have gaps - not only deleted records, but even if you start to enter a
record, change your mind, and hit <Esc> to cancel, you'll "use up" an
autonumber. Some developers never use autonumbers at all; most do, but
keep them "under the hood" as linking fields, concealed from the user.

If you want to count records, don't (EVER!) use the ID number to do
so. Instead, do a totals query and... count the records that are
there.

If you need a human readable sequential ID number, it's best not to
use autonumber; instead, use a Long Integer and VBA code to assign the
values.

John W. Vinson[MVP]
 
Reply With Quote
 
=?Utf-8?B?QWNjZXNzVGF4TWFu?=
Guest
Posts: n/a
 
      1st Feb 2006
To clear out records and make it as if they were never there, try this:

With your database open, click on File - Get External Data - Import.
Navigate to you database (yes, the same one) in the Import Dialog Box.
Choose the Tables Tab, and hylite the table that you want to start over with.
Here's the important part - click on the Options >> Button, and select the
Import Tables Definition Only radio button. Click OK. This effectively
copies only the design, and gives you a pristine table to start over with.
(The Table Name probably has a "1" added to the old name. Delete the old
table, rename the new.) Any autonumber feature will start over. However, as
John mentioned, this doesn't prevent gaps from occuring in the future.

"John Vinson" wrote:

> On Tue, 31 Jan 2006 12:58:27 -0800, "nikki"
> <(E-Mail Removed)> wrote:
>
> >I have been entering "fake" data into my database while creating it and now I
> >am ready to enter the real data, but need to get rid of the old records. I
> >know I can simply delete selected records, but whenever I do that, there is
> >always a gap in the record ID numbers and the count if off. How do I
> >completely clear out records from a database to make it as if they were never
> >there. Anyone with experience on this, I would love the help!

>
> A Delete query
>
> DELETE * FROM tablename;
>
> will delete all records (if you have relational integrity enforced,
> you'll need to run these delete queries in the right order, "many"
> side tables first).
>
> Autonumbers ARE NOT counts, and ARE NOT suitable for "record ID
> numbers' which will be seen by people. An autonumber will *always*
> have gaps - not only deleted records, but even if you start to enter a
> record, change your mind, and hit <Esc> to cancel, you'll "use up" an
> autonumber. Some developers never use autonumbers at all; most do, but
> keep them "under the hood" as linking fields, concealed from the user.
>
> If you want to count records, don't (EVER!) use the ID number to do
> so. Instead, do a totals query and... count the records that are
> there.
>
> If you need a human readable sequential ID number, it's best not to
> use autonumber; instead, use a Long Integer and VBA code to assign the
> values.
>
> John W. Vinson[MVP]
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clear Records =?Utf-8?B?QWJkdWwgU2hha2VlbA==?= Microsoft Access Forms 3 15th Nov 2007 05:59 AM
Using Dataset.Clear() to clear an SQL-database Cub71 Microsoft C# .NET 3 15th Nov 2006 03:32 PM
clear records marco_pb via AccessMonster.com Microsoft Access Form Coding 3 22nd Jun 2006 03:27 PM
Datagrid clear and add records =?Utf-8?B?TWlrZSBM?= Microsoft C# .NET 4 14th Sep 2005 04:12 AM
Clear Records Heather Microsoft Access VBA Modules 2 31st Aug 2004 08:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:36 PM.