filtrationproducts
asked on
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 .RecordCou nt = 0 Then Me.PrimaryLinkBtn.Enabled = False Else Me.PrimaryLinkBtn.Enabled = True
Is there a simple way to work around this?
Thanks,
Dan
I have narrowed it down to this line of code on the on_Current event.
'If Me.Child124.Form.Recordset
Is there a simple way to work around this?
Thanks,
Dan
ASKER
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
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
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
Dan
OK. Great!
/gustav
/gustav
ASKER
Found solution myself after posting question
If Not Me.NewRecord Then
If Me.Child124.Form.Recordset
Me.PrimaryLinkBtn.Enabled = False
Else
Me.PrimaryLinkBtn.Enabled = True
End If
End If
/gustav