Problem with RecordsetClone when form has filter property set

J

John F

Following routine executes in response to a custom event raised from another
form. Creates RecordSetClone, uses FindFirst to locate a specific record,
and then sets form’s RecordSet bookmark to equal RecordSetClone’s bookmark.

When form filter property is not set, this works fine, but when the form’s
filter property is set, I get an Run-time Error 2455 – You entered an
expression that has an invalid reference to the property |.

This error occurs at the statement: Me.Bookmark = rsCdrl.Bookmark

I’m fairly sure that the record found by FindFirst is consistent with the
form’s filter.

Any ideas why this is not working when the form is filtered. (I have search
for 2455 but do not find the issues already raised pertain to this.)

Thanks,

John

----------------------------------------------

Private Sub frmSub_MoveSubm(strSeqNo As String)
'Respond to the MoveSubm event on frmSubmissions
'Save the strSeqNo passed

Dim rsCdrl As Recordset

If Not IsNull(strSeqNo) Then
'Save before move
If Me.Dirty Then
Me.Dirty = False
End If
'Search in the clone set
Set rsCdrl = Me.RecordsetClone
rsCdrl.FindFirst "[chrSeqNo] = " & "'" & strSeqNo & "'"
If rsCdrl.NoMatch Then
MsgBox "Problem with string---jf"
Else
'Display the found record in the form.
Me.Bookmark = rsCdrl.Bookmark
End If
Set rsCdrl = Nothing


End If

End Sub
 
M

Marshall Barton

John F said:
Following routine executes in response to a custom event raised from another
form. Creates RecordSetClone, uses FindFirst to locate a specific record,
and then sets form’s RecordSet bookmark to equal RecordSetClone’s bookmark.

When form filter property is not set, this works fine, but when the form’s
filter property is set, I get an Run-time Error 2455 – You entered an
expression that has an invalid reference to the property |.

This error occurs at the statement: Me.Bookmark = rsCdrl.Bookmark

I’m fairly sure that the record found by FindFirst is consistent with the
form’s filter.

Any ideas why this is not working when the form is filtered. (I have search
for 2455 but do not find the issues already raised pertain to this.)
----------------------------------------------
Private Sub frmSub_MoveSubm(strSeqNo As String)
'Respond to the MoveSubm event on frmSubmissions
'Save the strSeqNo passed

Dim rsCdrl As Recordset

If Not IsNull(strSeqNo) Then
'Save before move
If Me.Dirty Then
Me.Dirty = False
End If
'Search in the clone set
Set rsCdrl = Me.RecordsetClone
rsCdrl.FindFirst "[chrSeqNo] = " & "'" & strSeqNo & "'"
If rsCdrl.NoMatch Then
MsgBox "Problem with string---jf"
Else
'Display the found record in the form.
Me.Bookmark = rsCdrl.Bookmark
End If
Set rsCdrl = Nothing
End If
End Sub


That's weird, even if I have no idea how a custom event can
affect the situation. All I can say is that I have had so
many problems with the Filter property that I stopped using
it long ago. (I have heard rumors that the problems are
fixed(?) in A2007).

The way around the Filter property is to reconstruct the
form's RecordSource query to include the criteria in its
WHERE clause. This only takes one or two more lines of code
so it's usually not a big deal.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top