Hello all. Please consider the following code (from which I have removed statements I believe to be irrelevant to my question. The code appears in a combo AfterUpdate event on a main form. The cbo is used to select a record in order to display related records in the subform. The code sets the subform to the record that had been current when leaving the prior session.):
When run as written, it works as expected. There is no error. However if the line in blue is replaced by the line in red, then the bookmark assignment (indicated by the arrow) throws a 3159 error "not a valid bookmark."
My question is why? The query in the red 'Set rst' statement is the same as the recordsource for the form referenced in the blue 'Set rst' statement. I realize the blue statement uses a recordsetclone, but aren't the two objects functionally equivalent ?
I'm trying to deepen my understanding of the recordset object and ways to use it. Thanks for any insight,
-Ron
Code:
Dim varID As Variant
Dim strDelim As String
Dim rst As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb()
strDelim = """"
varID = DLookup("fldValue", "tblInterSessionPlacemark", "[fldVariable] = 'fldShotIDLast'")
[COLOR=Teal] [COLOR=RoyalBlue]Set rst = Form!ctlsbfShotList.Form.RecordsetClone[/COLOR][/COLOR]
' [COLOR=Red] Set rst = db.OpenRecordset("qrysbfShotList")[/COLOR]
With rst
.MoveLast 'To ensure recordset is filled.
.FindFirst "[ShotNumber] & [ShotNumSuffix] = " & strDelim & varID & strDelim
If Not .NoMatch Then
Me!ctlsbfShotList.Form.Bookmark = .Bookmark [COLOR=DarkOrange] '<===[/COLOR]
End If
End With
rst.Close
Set rst = Nothing
My question is why? The query in the red 'Set rst' statement is the same as the recordsource for the form referenced in the blue 'Set rst' statement. I realize the blue statement uses a recordsetclone, but aren't the two objects functionally equivalent ?
I'm trying to deepen my understanding of the recordset object and ways to use it. Thanks for any insight,
-Ron
Last edited: