M
martinmike2
Hello,
I have an employee database with an archive table. I am trying to,
when a person leaves, to remove their data from all of my tables and
send only specific data to the archive table. The data that is going
to the archive table is in a table by itself and is not my problem.
My problem is that I dont think my code is actually correct. I have
not tested this yet because it just dosn't look right to me.
Another problem is that some of the tables have multiple records
pertaining to each person. All of the fields have a common field of
[SSN]. Part of my problem is that I dont know how to delete multiple
rows from a table with VBA.
My code is as follows:
Private Sub cmdTransfer_Click()
Dim db As DAO.Database, rst As DAO.Recordset
Set db = CurrentDb
Set rst = DBEngine(0)(0).OpenRecordset("SELECT * FROM tblSOD WHERE
[SSN] = " & gSSN)
If IsNull(rst) Then
Set rst = Nothing
Else
rst.Edit
rst.Delete
rst.Update
Loop
Set rst = Nothing
End If
End Sub
this sequence would then be repeated for each table in the database.
Is there a less cumbersome way?
Any help is greatly appreciated.
-Mike
I have an employee database with an archive table. I am trying to,
when a person leaves, to remove their data from all of my tables and
send only specific data to the archive table. The data that is going
to the archive table is in a table by itself and is not my problem.
My problem is that I dont think my code is actually correct. I have
not tested this yet because it just dosn't look right to me.
Another problem is that some of the tables have multiple records
pertaining to each person. All of the fields have a common field of
[SSN]. Part of my problem is that I dont know how to delete multiple
rows from a table with VBA.
My code is as follows:
Private Sub cmdTransfer_Click()
Dim db As DAO.Database, rst As DAO.Recordset
Set db = CurrentDb
Set rst = DBEngine(0)(0).OpenRecordset("SELECT * FROM tblSOD WHERE
[SSN] = " & gSSN)
If IsNull(rst) Then
Set rst = Nothing
Else
rst.Edit
rst.Delete
rst.Update
Loop
Set rst = Nothing
End If
End Sub
this sequence would then be repeated for each table in the database.
Is there a less cumbersome way?
Any help is greatly appreciated.
-Mike