Need to (force) the refresh of the MS Access database immediately after the delete statement
I use an MS Access database. In the code below, I loop through a recordset and delete each record. Directly after the delete statement, the function RefreshPlanning perform a select query based on the same table. The problem is that the record is not instantly deleted in the table and so the RefreshPlanning is querying some record who normally has been deleted! So I need to refresh the db (empty the cache?) instantly after the delete statement. How can I proceed?
Dim rstTraitements as ADODB.Recordset
Set rstTraitements = SelectQuery("SELECT * FROM tblTraitements WHERE ID like 123")
' Loop through all selected elements.
While Not rstTraitements.EOF
' Delete current record in the table.
rstTraitements.Delete
MsgBox "a database refresh is needed here before the next statement"
RefreshPlanning DatePlanning, CodeEquipement
rstTraitements.MoveNext
Wend
Remark 1: SelectQuery is a function who return a recordset
Remark 2: RefreshPlanni开发者_StackOverflow社区ng is a function who perform a select query based on the same table (tblTraitements).
Thank you for your help.
Try
rstTraitements.Resync
or
rstTraitements.Requery
after the delete
精彩评论