I'm back, thanks for the help with the import, our first import went with minor clitches, mostly with the spreadsheets. On to the next stage. I need to archive the main table of my database. Basically, I just want all of the info to move to fromtblClientCo ntact to tblClientContac tArchive. Please advise
Archiving data
Collapse
X
-
Originally posted by rcollinsI'm back, thanks for the help with the import, our first import went with minor clitches, mostly with the spreadsheets. On to the next stage. I need to archive the main table of my database. Basically, I just want all of the info to move to fromtblClientCo ntact to tblClientContac tArchive. Please adviseCode:[B]Dim strSQL As String DoCmd.CopyObject , "tblCientContactArchive", acTable, "tblClientContact" 'DELETE ALL Records from tblClientContact DoCmd.SetWarnings False 'don't feel like seeing Deletion Prompts! strSQL = "DELETE * FROM tblClientContact;" DoCmd.RunSQL strSQL DoCmd.SetWarnings True[/B]
-
So, real screwy behavior. When I run this code, it copies over, then deletes from the original table. As soon as it deletes from the original, then all of the data in the archive is gone also. If this isn't bad enough, when I paste the info back in my original table, the data in the archive comes back. I looked in the link table manager to find that there is a link from the archive table to the original table. How can I use a table that is already created. If I make an archive table, it prompts to replace the existing one, then links the new one with the original table.Comment
-
Originally posted by rcollinsSo, real screwy behavior. When I run this code, it copies over, then deletes from the original table. As soon as it deletes from the original, then all of the data in the archive is gone also. If this isn't bad enough, when I paste the info back in my original table, the data in the archive comes back. I looked in the link table manager to find that there is a link from the archive table to the original table. How can I use a table that is already created. If I make an archive table, it prompts to replace the existing one, then links the new one with the original table.Comment
-
Originally posted by rcollinsDid we ever find an answer to this?
[CODE=vb]Dim strSQL As String
DoCmd.CopyObjec t , "tblCientContac tArchive", acTable, "tblClientConta ct"
'DELETE ALL Records from tblClientContac t
DoCmd.SetWarnin gs False 'don't feel like seeing Deletion Prompts!
strSQL = "DELETE * FROM tblClientContac t;"
DoCmd.RunSQL strSQL
DoCmd.SetWarnin gs True
RefreshDatabase Window 'Add this line of code[/CODE]Comment
-
How about this.. I had to make 2 more querys, one to append to the archive table and one to delete the records from the original table. This worked great.
Code:Private Sub Command30_Click() If MsgBox("Are you sure you want to do this? This process will move all of the records for the past year to an 'archive' table!", vbYesNo) = vbYes Then DoCmd.SetWarnings False 'put new records in archive table DoCmd.OpenQuery "qryAppentClientContactArchive" 'deletes records from original table DoCmd.OpenQuery "deleterecordsforarchive" DoCmd.SetWarnings True MsgBox "All records have been archived.", vbInformation End If End Sub
Comment
Comment