Link to home
Start Free TrialLog in
Avatar of Rob4077
Rob4077Flag for Australia

asked on

object invalid or no longer set

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
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rob4077


Thanks for that. Problem solved!