Smart questions
Smart answers
Smart people

Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Error: Object invalid or no longer set?? Can you help?

jasonmac (Programmer) (OP)
12 Apr 04 14:34
Hello everyone.  I'm using access '97 and I'm getting an error that I don't know how to correct.  I have a form with a subform and as I go through the records and come to a record that has data in the subform I get this error.

"Object invalid or no longer set."  The error seems to be in the on current event.  Here it is:


Private Sub Form_Current()
Dim recClone As Recordset
    If Me.NewRecord Then
        cmdNewRecord.Enabled = False
        cmdAdd.Enabled = True
        cmdCloseForm.Visible = False
        Me.cmdCancel.Visible = True
        cmdNewRecord.Enabled = True
        cmdAdd.Enabled = False
    End If
    If Me.NewRecord Then
        cmdFirstRecord.Enabled = False
        cmdNext.Enabled = False
        cmdBack.Enabled = False
        cmdLastRecord.Enabled = False
        Exit Sub
    End If

'Me.Recordsetclone = <object invalid or no longer set>
    Set recClone = Me.RecordsetClone

    If recClone.RecordCount = 0 Then  
         cmdFirstRecord.Enabled = False
         cmdNext.Enabled = False
         cmdBack.Enabled = False
         cmdLastRecord.Enabled = False
         recClone.Bookmark = Me.Bookmark
         cmdFirstRecord.Enabled = Not recClone.BOF
         cmdBack.Enabled = Not recClone.BOF
         cmdLastRecord.Enabled = Not recClone.EOF
         cmdNext.Enabled = Not recClone.EOF
    End If
         Set recClone = Me.RecordsetClone
End Sub

Am I missing something?  Can anyone help me?  

Thanks in advance,
lupins46 (MIS)
12 Apr 04 15:01
The problem is your last statement.

You never open the recordset so you shouldn't close it.

I'm not sure what the point is of the last but one statement either.
jasonmac (Programmer) (OP)
12 Apr 04 15:27
I removed the "recClone.Close"
statement but there is no change. Any other ideas?

jasonmac (Programmer) (OP)
12 Apr 04 16:54
When I remove the subform from the form it works perfectly.  Does that help?
lupins46 (MIS)
13 Apr 04 6:07
To try to diagnose the problem rename the procedure and create a new Form current procedure with just this

Private Sub Form_Current()
Dim recClone As Recordset
Set recClone = Me.RecordsetClone
Set recClone = nothing
end sub

See if you get any errors.
jasonmac (Programmer) (OP)
13 Apr 04 8:41

I did what you said and now it seems to work okay.  However, I still get the error when I have the form open then switch to design view.  Once I switch from design view to runtime I get the error again.  when I close the form all together and reopen it the error is not there.  Do you know why this might be happening.  I hope I've explained it well enough.  

steps to get error:
1. open form
-no error
2. switch to design view
3. switch back to runtime
4. close form
5. open form
-no error

Thanks again,
jasonmac (Programmer) (OP)
13 Apr 04 10:03
I'm stumped on this can someone PLEASE help?
jasonmac (Programmer) (OP)
13 Apr 04 10:23
Once again when I remove the subform everything works fine.  What is going on?  Sorry to sound pushy but this is becoming an urgent matter here.  

hymn (TechnicalUser)
13 Apr 04 11:30
have a look at the code I use for navigation, it is in


You should be able to pick out what you require

Hope this helps

lupins46 (MIS)
13 Apr 04 11:59
I assume the code you have shown is in the main form, not the subform?
How is the subform linked to the main form?
Is the subform a single form or a continuous form ?(or something else?)

If the code works correctly when you don't go into design view then this would qualify as 'working' wouldn't it?
jasonmac (Programmer) (OP)
13 Apr 04 13:00
Yes the code is in the main form.  The subform is linked to the main form by one field. Child field is RFQnum, Master field is RFQNumber.  The subform is a continuous form.  Yes it would Qualify as working but that is just with the sample code you supplied.  When I add the rest of my code it errors out as soon as I come across a record with corrisponding records in the subform.  However when I eliminate the subform, my code works perfectly.  Hope this helps.  

Thanks again,
jasonmac (Programmer) (OP)
13 Apr 04 13:21

I used your code and just like before it works perfectly until I get to a record that has data in the subform then it errors out.  Also when I eliminate the subform it works perfectly.  I know it has somethign to do with this subform but I don't know what.  

lupins46 (MIS)
13 Apr 04 14:15
I have tried your original code (minus the last two lines) on a form/subform created from northwind orders and order details tables and it works fine.

So we have to start looking at your Access installation.
Do you have the service eleases for Office 97 installed?

The other area to consider is what code you have in the subform.
jasonmac (Programmer) (OP)
13 Apr 04 14:56
Thank you for all your help everyone.  I have found the problem.  It was some code in my subform that I was using for security purposes.  I can't believe I didn't find it sooner.  Mostly I just forgot it was there.  Thanks for pointing me in the right direction lupins.  I very much appreciate all of your help.  

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close