troubleshooting Question

object invalid or no longer set

Avatar of Rob4077
Rob4077Flag for Australia asked on
Microsoft Access
2 Comments1 Solution280 ViewsLast Modified:
I have a form with a few controls that affect the recordsource of a combo box on my form so I have set the On GotFocus event of the combo box to requery, which works fine. I then tried to extend the code to set the value to the first record in the underlying recordset if there's only one element in the recordset (see the code below). The requery runs fine but I get an "object invalid or no longer set" error in the line that follows the requery. Any suggestions as to what might be causing the error?
    If Me.cboDetailid.Recordset.RecordCount = 1 Then  '<<< the error occurs here
        Me.cboDetailid = CLng(Me.cboDetailid.ItemData(0))
    End If
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros