View Full Version : archive older entries?


fusion501
01-12-2007, 05:36 PM
Hi, we have a database for keeping record of our games (unreal tournament games).... Its just a simple database and we enter our results based on the following fields: -

Opponent:
Game Type:
Players:
Maps:
Date:
Result:

the file has started to get quite big and wondered if it would be possible to automatically move entries say that were older than a month old to a new table, or archive table. Im not a big access genious so i hope i have explained enough for you to understand what im trying to do here.

Thank you for your time, much appreciated.

Wiz47
01-12-2007, 10:10 PM
Hi, we have a database for keeping record of our games (unreal tournament games).... Its just a simple database and we enter our results based on the following fields: -

Opponent:
Game Type:
Players:
Maps:
Date:
Result:

the file has started to get quite big and wondered if it would be possible to automatically move entries say that were older than a month old to a new table, or archive table. Im not a big access genious so i hope i have explained enough for you to understand what im trying to do here.

Thank you for your time, much appreciated.

Move it to a shell of the old table, then delete it from the current db


Private Sub cmdMove_Click()
Dim i As Integer
Dim rsOld As DAO.Recordset
Dim rsNew As DAO.Recordset
Set rsNew = CurrentDb.OpenRecordset("SELECT * FROM Employees_Archive")
Set rsOld = CurrentDb.OpenRecordset("SELECT * FROM Employees WHERE(EmployeeID=" & Me.tbCtID & ")")
rsNew.AddNew
For i = 0 To rsOld.Fields.Count - 1
rsNew.Fields(i).Value = rsOld.Fields(i).Value
Next
rsNew.Update

rsNew.Close
rsOld.Close
Set rsNew = Nothing
Set rsOld = Nothing
End Sub



Private Sub cmdDelete_Click()
cmdMove_Click
If MsgBox("Deleting This Record will Affect The Whole Database" & vbCrLf & " Do You Really Want To Delete It?", vbInformation + vbYesNo, "DELETE RECORD!") = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE * FROM Employees WHERE (CtID=" & Me.tbCtID & ")"
Me.Requery ' this will requery the form.
DoCmd.SetWarnings True
Else
Exit Sub
End If
End Sub