Hi Gurus,
I am getting the error 3420 "object invalid or no longer set" at in
the line -- rst.FindFirst "[ClientID]=" & NextPK --in the code below.
I simply have a continuous main form that is, by default, based on
qryClients, which only shows active or current clients. Users can
click a button that switches the record source to qryClientInactive,
which shows active AND inactive clients. There is a field,
txtInactive (a fancy wingdings checkmark, =IIf([Active_Inactive],Chr
$(252),Chr$(32))) covering a check box named Active_Inactive that when
clicked, automatically runs the code below.
However, since it requeries the recordsource, the first record gets
the focus afterwards. So, I'm trying to capture the primary key of
the record that is immediately after a record that is to be marked as
inactive, so the user can be positioned on the next record. I could
not figure this out after spending much time reviewing posts by Wayne
Gillespie and others similar to this. Any help would be much
appreciated. Thanks.
================
Dim rst As DAO.Recordset
Dim NextPK As Long
Set rst = Me.RecordsetClone
rst.MoveNext
NextPK = rst!ClientID
Me.Active_Inactive = Not Me.Active_Inactive
If Me.Active_Inactive = True And Me.RecordSource = "qryClients" Then
Me.RecordSource = "qryClientsInactive"
Me.RecordSource = "qryClients"
Me!cboClients.Requery
rst.FindFirst "[ClientID]=" & NextPK
Me.Bookmark = rst.Bookmark
ElseIf Me.Active_Inactive = True And Me.RecordSource =
"qryClientsInactive" Then
Me.RecordSource = "qryClients"
Me.RecordSource = "qryClientsInactive"
Me!cboClients.Requery
rst.FindFirst "[ClientID]=" & NextPK
Me.Bookmark = rst.Bookmark
ElseIf Me.Active_Inactive = False And Me.RecordSource = "qryClients"
Then
Me.RecordSource = "qryClientsInactive"
Me.RecordSource = "qryClients"
Me!cboClients.Requery
rst.FindFirst "[ClientID]=" & NextPK
Me.Bookmark = rst.Bookmark
ElseIf Me.Active_Inactive = False And Me.RecordSource =
"qryClientsInactive" Then
Me.RecordSource = "qryClients"
Me.RecordSource = "qryClientsInactive"
Me!cboClients.Requery
rst.FindFirst "[ClientID]=" & NextPK
Me.Bookmark = rst.Bookmark
End If