I have an ms access database with 24 tables. I need to rename the tables every day from
table 1 --> table 1backup
any ideas will be appreciated.
Is it doable with VBA?
You can:
Dim tdf As TableDef
For Each tdf In CurrentDb.TableDefs
If Left(tdf.Name, 4) <> "MSys" Then
tdf.Name = tdf.Name & "_backup"
End If
Next
I would suggest below code. It would replace newly renamed table, with the existed table, if already has existed with the new table name:
Dim tdf As TableDef
For Each tdf In CurrentDb.TableDefs
If Left(tdf.Name, 7) <> "backup_" Then
Dim newTableName As String
newTableName = "backup_" + tdf.Name
DoCmd.SetWarnings False
DoCmd.Rename newTableName, acTable, tdf.Name
DoCmd.SetWarnings True
End If
Next
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With