I want to take all the fields in TBLCommissionTr ansactions in current DB and make a new table in T:\folder\TblBa ckups.mdb and append today’s date and time to the new table name. This is purely for archival purposes.
Sorry, not really well versed in VBA. I have the following code which I modified from search online. When I run it I get the message "Query input must contain at least one table or query" which I am suspecting is failing on strTableName but don't really know for sure. I have played around with it and can't get it to work. What am I doing wrong?
Sorry, not really well versed in VBA. I have the following code which I modified from search online. When I run it I get the message "Query input must contain at least one table or query" which I am suspecting is failing on strTableName but don't really know for sure. I have played around with it and can't get it to work. What am I doing wrong?
Code:
Private Sub BackupTblCommissions_Click() Dim strTableName As String Dim strFilename As String Dim strSQL As String strFilename = "T:\folder\TblBackups.mdb" strTableName = "TBLCommissionTransactions" & Format(Now(), "yyyymmdd-hhmm") strSQL = "SELECT TBLCommissionTransactions.* INTO " & strTableName & " IN " & _ strFilename & " FROM TBLCommissionTransactions;" CurrentDb.Execute strSQL End Sub
Comment