Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a table with the current date as part of the name

Status
Not open for further replies.

travsab

Programmer
Apr 7, 2008
3
US
hi, every month i have to back up the previous months tables by adding the month to the name..ie: customer table 08012008 ... i am doing this manulaly... is there any code that can do this for me? thanks! sabrina
 
An easy way to copy a table is to use :

DoCmd.SetWarnings False
DoCmd.RunSQL "SELECT * INTO newtablename FROM oldtablename WHERE 1=2"
DoCmd.SetWarnings True

This will copy the table dict to a new tablename of your choice without data. REmove out the where 1=2 to copy data too.

 
Sorry forgot to add the tablename portion...you could use the following:

strNewtablename = Replace(Date(),"/","")
 
are you replacing the name of the table with the date? i want to make the date part of the table name for a backup version. thanks sabrina
 
Sabrina,
I'm not sure what you are asking for...you can concatenate the old table name with the current date to get the "new" table name.

strNewtablename = "OLDTABLENAME" & Replace(Date(),"/","")

If the table name was "MYTABLE" you would get:

strNewtablename = "MYTABLE10102008
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top