Question : How do I delete all records from an ADODB recordset?

Hello,

Given certain conditions, I would like to delete all the records in an ADODB recordset.  Please refer to the code below.  Essentially, I am comparing two recordsets, rstDossier and rstTemp.  If rstTemp is empty, however, I would just like to delete all the records in rstDossier and then exit the sub.  

What is the correct code for deleting all the records from rstDossier?

Thank you and regards,
Saleve
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
Dim rstDossier As ADODB.Recordset
Dim rstTemp As ADODB.Recordset
Dim sql As String
Set rstDossier = New ADODB.Recordset
Set rstTemp = New ADODB.Recordset

'Define and Open recordset of tbl_Dossier
sql = "SELECT tbl_Dossier.* FROM tbl_Dossier;"

rstDossier.Open sql, CurrentProject.Connection, _
         adOpenStatic, adLockOptimistic
         
'Define and Open recordset of tbl_TempDossierRecordSource
sql = "SELECT tbl_tempDossierRecordSource.* FROM tbl_tempDossierRecordSource;"
     
rstTemp.Open sql, CurrentProject.Connection, _
         adOpenStatic, adLockOptimistic
         
'Compare both recordsets and update tbl_Dossier to reflect tempDossierRecordSource
    
'Delete: remove records from tbl_Dossier that are not in the temp table
'if there are no records left in the temp table
'then delete all records in tbl_Dossier and exit sub
      If rstTemp.RecordCount = 0 Then

Answer : How do I delete all records from an ADODB recordset?

Is it not rstdossier.delete?
Random Solutions  
 
programming4us programming4us