Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Archiving data

Status
Not open for further replies.

cav

MIS
Feb 3, 2000
49
US
Projects and hours are entered into a database for up to 200 employee for any given day--I would like to periodically archive these records just in case we had to go back. What is the easiest way to set up for the end user to archive. Thanks for all suggestions. [sig][/sig]
 
Use a listbox to select the records for archiving, with a command button to run a SQL command to archive the selected records. Something like the following code

Code:
Dim Y As Variant
Dim strSQL1 As String, strSQL2 As String, strSQL3 As String
Dim strSource1 As String, strDest1 As String, strDelete As String

strSQL1 = "INSERT INTO "
strSQL2 = " SELECT * FROM "
strSQL3 = " WHERE [RecordID] = "
    
strDest1 = "Destination Table"
strSource1 = "Source table"
strDelete = "Delete [Source Table].* FROM [Source Table] WHERE [Source Table].RecordID = "

For intCurrentRow = 0 To Me!lstSource.ListCount - 1
If Me!lstSource.Selected(intCurrentRow) Then
   Y = Me!lstSource.ItemData(intCurrentRow)
'Turn off the Access warning messages
Code:
   DoCmd.SetWarnings False
   DoCmd.RunSQL strSQL1 & strDest1 & strSQL2 & strSource1 & strSQL3 & Y, False
'Delete the record now that it is archived
Code:
   DoCmd.RunSQL strDelete & Y, False
End If
Next intCurrentRow

Hope this helps
Lightning
[sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top