L
Le Tran
Hi all,
Here is the code.
Private Sub Command4_Click()
Dim qd As Querydef
Dim db As DAO.Database
Dim prm As DAO.Parameter
Set db = CurrentDb
Set qd = db.QueryDefs("QUpdateStatusinFacch")
For Each prm In qd.Parameters
prm.Value = Eval(prm.Name)
Next prm
qd.Execute dbFailOnError
Set qd = db.QueryDefs("QAppendInActiveStatustoArchive")
qd.Execute
Set qd = db.QueryDefs("QDeleteInactiveInFacch")
qd.Execute
MsgBox qd.RecordsAffected & " Records were Updated", vbOKOnly, " UpdateStatus"
End Sub
What I do is input two parameters. run the update query "QUpdateStatusinFacch" then run the Append query" QAppendInActiveStatustoArchive" that move this record to archive table. The run the Delete Query "QDeleteInactiveInFacch" that delete this record from the table.
My question, Do this is the good way to this. are there any ways that I can do for more safe than this way. Or some one can help me with trap error in this code.
Thanks in advance,
Here is the code.
Private Sub Command4_Click()
Dim qd As Querydef
Dim db As DAO.Database
Dim prm As DAO.Parameter
Set db = CurrentDb
Set qd = db.QueryDefs("QUpdateStatusinFacch")
For Each prm In qd.Parameters
prm.Value = Eval(prm.Name)
Next prm
qd.Execute dbFailOnError
Set qd = db.QueryDefs("QAppendInActiveStatustoArchive")
qd.Execute
Set qd = db.QueryDefs("QDeleteInactiveInFacch")
qd.Execute
MsgBox qd.RecordsAffected & " Records were Updated", vbOKOnly, " UpdateStatus"
End Sub
What I do is input two parameters. run the update query "QUpdateStatusinFacch" then run the Append query" QAppendInActiveStatustoArchive" that move this record to archive table. The run the Delete Query "QDeleteInactiveInFacch" that delete this record from the table.
My question, Do this is the good way to this. are there any ways that I can do for more safe than this way. Or some one can help me with trap error in this code.
Thanks in advance,