Trying to delete all tables after 3 days. It doesnt work. What's wrong?
Function delTBackupDatabase() Dim db As DAO.Database Dim tdf As DAO.TableDef Set db = CurrentDb For Each tdf In db.TableDefs If ("TBackupDatabase " & Format(Date, "dd/mm/yyyy")) < (Date - 3) Then DoCmd.DeleteObject acTable, tdf.Name End If Next Access.RefreshDatabaseWindow End Function
will never work.you're comparing a string against a date?
If ("TBackupDatabase " & Format(Date, "dd/mm/yyyy")) < (Date - 3) Then
Normally, you delete records, or archive them. Add a Date\Time field to track the entries so you can sort/filter/...
What happens exactly?
If the table is involved in relationships, then you won't be able to delete it until you delete the relationships first.