View Full Version : Create table in vba with current date appened to it


reginab
11-03-2005, 03:16 PM
I wrote the following code and it does not work. I would like to be able to copy the contents of one table to another table with the same name but with the current date appended to it. I'm getting extremely frustrated with this and I have asked other people here and no one seems to be able to help me. I originally tried to use the variable I created of "Backupfile" but that didn't work either.


Sub CreateTable()

Dim CurrentDate As Date
Dim BackupFileName As String
Dim strSql As String
Dim BackupFile As String
Dim dbs As Database
Dim qdf As QueryDef
Set dbs = CurrentDb

CurrentDate = Date
BackupFileName = "tbl_mstr_CTS_Raw_Data" & " " & CurrentDate


strSql = "SELECT tbl_MSTR_CTS_RAW_Data.* INTO tbl_mstr_CTS_Raw_Data" & " " & CurrentDate & _
"FROM tbl_MSTR_CTS_RAW_Data;"


dbs.Execute strSql





End Sub

Surjer
11-03-2005, 03:26 PM
Dim strSql As String

strSql = "SELECT tbl_MSTR_CTS_RAW_Data.* INTO [tbl_mstr_CTS_Raw_Data" & date & "] FROM tbl_MSTR_CTS_RAW_Data"

DoCmd.RunSQL strSql

reginab
11-04-2005, 06:42 AM
Thank you so much. This worked great. I will certainly use this site again.