Create table in vba with current date appened to it

reginab

Registered User.
Local time
Today, 08:53
Joined
Nov 3, 2005
Messages
10
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
 
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
 
Thank you so much. This worked great. I will certainly use this site again.
 

Users who are viewing this thread

Back
Top Bottom