473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Help with Error 3420 when Moving to Next Record after a Requery

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
Mar 21 '08 #1
2 3417
DFS
Arnold wrote:
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 think it occurs because you're changing the form's recordsource after
setting your clone.
Mar 21 '08 #2
Thanks!
Mar 21 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Norman Fritag | last post by:
Hi there, On a form I click a tickbox ("display",yes/No) that requires the recordset. =>>Code<<-- Me!PositionClosingDate = Format(Date, "Short Date") ' when was the position closed? Me.Requery...
8
by: Steve | last post by:
I have several pairs of synchronized subforms in an application. I have a Delete button for each pair that uses the following code or similar to delete a record in the second subform: ...
0
by: Jamey | last post by:
I perused old posts for an answer to this for at least an hour, and I've found a work-around, but no definitive answer. Synopsis of the problem: On NotInList or ctl.Requery commands where a...
37
by: Tim Marshall | last post by:
From http://www.mvps.org/access/tencommandments.htm 9th item: Thou shalt not use "SendKeys", "Smart Codes" or "GoTo" (unless the GoTo be part of an OnError process) for these will lead you...
4
by: dhcomcast | last post by:
We're starting to use Oracle for the back-end instead of a separate Access .mdb file for the data and everything as gone surprisingly well so far. We are learning Oracle as we go; Yikes! But we...
7
by: Mathew Butler | last post by:
I'm investigating an issue I have when pulling data back from MS access I'm retrieving all rows from a column in a table of 5000 rows - accessing a column of type "memo" ( can be 65353 character...
8
by: darnnews | last post by:
I have a form. When a person selects a publication from a listbox, this snippet of code is supposed to look up authors that correspond to that publication and populate the Author List Box, but...
0
by: Peter Newman | last post by:
vb.net 2003 Sql 2005 Ive been banging my head against a brick wall for the last day trying to figure out what im doing wrong I have a Dataset and a Form with text boxes that are bound to the...
6
by: woodey2002 | last post by:
Hi Everyone. Thanks for your time. I am trying to create a search form that will allow users to select criteria from multiple multi select boxes. So far i have managed to achieve a search option...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.