No Current Record Error when closing Access form

I have a form that is giving me a "No current record" error when I close the form from a (New) record.

I have narrowed it down to this line of code on the on_Current event.

'If Me.Child124.Form.Recordset.RecordCount = 0 Then Me.PrimaryLinkBtn.Enabled = False Else Me.PrimaryLinkBtn.Enabled = True

Is there a simple way to work around this?

Thanks,
Dan
LVL 1
filtrationproductsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
You can use:

If Not Me.NewRecord Then
    If Me.Child124.Form.Recordset.RecordCount = 0 Then
        Me.PrimaryLinkBtn.Enabled = False
    Else
        Me.PrimaryLinkBtn.Enabled = True
    End If
End If

/gustav
filtrationproductsAuthor Commented:
Gustav,

I tried that but unfortunately I still receive the "no current record" error when exiting. I read somewhere this had something to do with the "recordcount" command.

I am also confused as to why it errors when I close the form. I would think I would get the error right away when navigating to the new record.

But I know it has to be this line of code because when I comment it out/delete it I do not receive the errors anymore.

Dan
Gustav BrockCIOCommented:
But if you really are on a new record, the code will be skipped.

So, I guess, something else is going on.

Or rewrite your code. There should be no reason to enable/disable controls when you close the form.

/gustav
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

filtrationproductsAuthor Commented:
I figured out a solution. Use RecordsetClone instead of RecordSet.

http://www.access-programmers.co.uk/forums/showthread.php?t=139442

Dan

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
filtrationproductsAuthor Commented:
It was bypassing the code when I was on a new record, I setup a msgbox to make sure. But for some mysterious reason I would still get the error message. I think it had something to do with using that "recordset.recordcount" command at any point when the form is open. Because once that line of code ran (when I navigated through records) then exited the form on a New record it would error.

Dan
Gustav BrockCIOCommented:
OK. Great!

/gustav
filtrationproductsAuthor Commented:
Found solution myself after posting question
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.