I have a problem in the following code where I reach set rst2........
The problem is that the recordset may contain no records, i.e not even a blank record, because it is based on a complex query. When the module reached this point in code I get error "Too few parameters. Expected 2." If rst2 contained a normal blank tabel or query it would work fine. How could I get around this??????
Dim dbs As Database
Dim rst, rst2, rst3 As Recordset
Dim strsql, strsql2, strsql3, strsql4 As String
Set dbs = CurrentDb
strsql = "SELECT * FROM qryAdCollectionDuplicateAds"
strsql2 = "SELECT * FROM tblAdCollectionFormDuplicateAds"
Set rst = dbs.OpenRecordset(strsql2, dbOpenDynaset, dbSeeChanges)
Do Until rst.EOF
With rst
rst.Delete
End With
rst.MoveNext
Loop
rst.Close
Set rst2 = dbs.OpenRecordset(strsql, dbOpenDynaset, dbSeeChanges)
Do Until rst2.EOF
With rst2
strsql3 = rst2(0)
strsql4 = rst2(1)
Set rst3 = dbs.OpenRecordset(strsql2, dbOpenDynaset, dbSeeChanges)
With rst3
rst3.AddNew
rst3(0) = strsql3
rst3(1) = strsql4
End With
rst3.Update
rst3.Close
End With
rst2.MoveNext
Loop
rst2.Close
Set dbs = Nothing
The problem is that the recordset may contain no records, i.e not even a blank record, because it is based on a complex query. When the module reached this point in code I get error "Too few parameters. Expected 2." If rst2 contained a normal blank tabel or query it would work fine. How could I get around this??????
Dim dbs As Database
Dim rst, rst2, rst3 As Recordset
Dim strsql, strsql2, strsql3, strsql4 As String
Set dbs = CurrentDb
strsql = "SELECT * FROM qryAdCollectionDuplicateAds"
strsql2 = "SELECT * FROM tblAdCollectionFormDuplicateAds"
Set rst = dbs.OpenRecordset(strsql2, dbOpenDynaset, dbSeeChanges)
Do Until rst.EOF
With rst
rst.Delete
End With
rst.MoveNext
Loop
rst.Close
Set rst2 = dbs.OpenRecordset(strsql, dbOpenDynaset, dbSeeChanges)
Do Until rst2.EOF
With rst2
strsql3 = rst2(0)
strsql4 = rst2(1)
Set rst3 = dbs.OpenRecordset(strsql2, dbOpenDynaset, dbSeeChanges)
With rst3
rst3.AddNew
rst3(0) = strsql3
rst3(1) = strsql4
End With
rst3.Update
rst3.Close
End With
rst2.MoveNext
Loop
rst2.Close
Set dbs = Nothing