Delete and backup fields

jeppe

Registered User.
Local time
Today, 18:43
Joined
Jun 5, 2006
Messages
16
How can I delete fields which are older than 30 days and save these to backup?? I can delete all fields now..

Private Sub Command2_Click()
Dim msg As String

msg = MsgBox("Are you sure?", vbYesNo)
If msg = vbYes Then

Dim db As Database, rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Table")

db.Execute "DELETE * FROM
;"
rs.Close
db.Close

Else
msg = vbNo
End If
End Sub
 
Code:
Set brs = db.OpenRecordset("BackupTable", OpenDynaset)

rs.MoveFirst

With brs
      Do Until rs.EOF = True
        .Addnew
        !Fieldname = rs.Fieldname
        !Fieldname2 = rs.Fieldname2
        .Update
        .MoveNext
     Loop
End With

That should be done before the delete command. However, why are you doing this- this would denormalize the database? It'd be easier to add a checkbox to the table, label it "Archive" and have your forms use a query pulling only records that isn't checked. It'll be faster and efficient and less maintenece as well.
 

Users who are viewing this thread

Back
Top Bottom