how to copy table clean out original with code

L

Leslie Porter OHV

ide like to make a button on my form that will copy a table using the
european date code as a file name like this...

orig
clipdata

to
20080929-clipdata

then clearout the data in the table clipdata. this is to clear out the day.
but i also have a question. there is an auto number called id in the table.
will this also reset to 0 or 1 or keep the count that it has?
 
J

John Spencer

To copy the data

DoCmd.CopyObject , Format(Date, "yyyymmdd") & "-" & "clipData", _
acTable, "clipData"

To clear the data
Currentdb().Execute "DELETE * FROM clipData"

The autonumber in ClipData will not be reset to 0 or 1. It will continue to
increment.

Now the real question is WHY are you doing this. It would normally make more
sense to have a field in the table clipData that stored the date. If this is
the date of creation, you could just set the default value of the field in the
table to Date() and that would automatically be accomplished.

Once you have that date (indexed) you can use queries to select the data for
any specific date.


John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
L

Leslie Porter OHV

Now the real question is WHY are you doing this. It would normally make
more
sense to have a field in the table clipData that stored the date. If this is
the date of creation, you could just set the default value of the field in the
table to Date() and that would automatically be accomplished.

Once you have that date (indexed) you can use queries to select the data for
any specific date.

im backing up the table for one so the ying yangs using the program dont
messup the data any more than needed. plus there is no network cable out to
where the pc is so i have to trsansfer data ever day by thumb drive untill we
can live connect.
 
A

Administrator

Leslie Porter OHV said:
im backing up the table for one so the ying yangs using the program dont
messup the data any more than needed. plus there is no network cable out
to
where the pc is so i have to trsansfer data ever day by thumb drive untill
we
can live connect.
 
A

Administrator

Leslie Porter OHV said:
im backing up the table for one so the ying yangs using the program dont
messup the data any more than needed. plus there is no network cable out
to
where the pc is so i have to trsansfer data ever day by thumb drive untill
we
can live connect.
 
Top