T
tstevens
I am embarrassed to have to ask because what I wish to do seems so trivial.
Basically, I have a form with an underlying table and am using the latter to
prepare a new record. At a certain point, I want to filter all the records
with certain details in common with the new one. After filtering, I wish to
return to my new record. So it looks as if I want to set a bookmark prior to
filtering and to reset my form to it afterwards. I am attempting this from
the click event handler of a command button. My latest attempt looks as
follows:
Option Compare Database
Private Sub cmdApplyFilter_Click()
On Error GoTo Err_cmdApplyFilter_Click
Dim strWhere As String
Dim rst As Recordset
Set rst = Me.RecordsetClone
rst.Bookmark = Me.Bookmark
Code to construct strWhere
Me.Filter = strWhere
Me.FilterOn = True
Me.Bookmark = rst.Bookmark
Me.Counter.Value = DCount("[Counter]", "[Archive]", strWhere)
Exit_cmdApplyFilter_Click:
Exit Sub
Err_cmdApplyFilter_Click:
MsgBox Err.Description
Resume Exit_cmdApplyFilter_Click
End Sub
With the above, I get an immediate type mismatch when I try to Set rst. If
I declare rst as Object, the set command goes through - but when I try to
apply the bookmark later, I get a message that rst is no longer set! (Can't
think what I did to unset it.) It I try to store the bookmark as a variant,
I get an illegal bookmark message when I try to reapply it.
I am using MSAccess 2002. This looks to be relevant since there are
different styles evident in various historic postings; so it likely affects
how I should be declaring rst.
I am new at databases but have experience in VB.Net programming for other
Windows XP applications. The rules for Access appear to me to be something
like VB6.
Basically, I have a form with an underlying table and am using the latter to
prepare a new record. At a certain point, I want to filter all the records
with certain details in common with the new one. After filtering, I wish to
return to my new record. So it looks as if I want to set a bookmark prior to
filtering and to reset my form to it afterwards. I am attempting this from
the click event handler of a command button. My latest attempt looks as
follows:
Option Compare Database
Private Sub cmdApplyFilter_Click()
On Error GoTo Err_cmdApplyFilter_Click
Dim strWhere As String
Dim rst As Recordset
Set rst = Me.RecordsetClone
rst.Bookmark = Me.Bookmark
Code to construct strWhere
Me.Filter = strWhere
Me.FilterOn = True
Me.Bookmark = rst.Bookmark
Me.Counter.Value = DCount("[Counter]", "[Archive]", strWhere)
Exit_cmdApplyFilter_Click:
Exit Sub
Err_cmdApplyFilter_Click:
MsgBox Err.Description
Resume Exit_cmdApplyFilter_Click
End Sub
With the above, I get an immediate type mismatch when I try to Set rst. If
I declare rst as Object, the set command goes through - but when I try to
apply the bookmark later, I get a message that rst is no longer set! (Can't
think what I did to unset it.) It I try to store the bookmark as a variant,
I get an illegal bookmark message when I try to reapply it.
I am using MSAccess 2002. This looks to be relevant since there are
different styles evident in various historic postings; so it likely affects
how I should be declaring rst.
I am new at databases but have experience in VB.Net programming for other
Windows XP applications. The rules for Access appear to me to be something
like VB6.