troubleshooting Question

MS Access: Error when form is unloaded by Design View

Avatar of Shadi Saleh
Shadi Saleh asked on
DatabasesMicrosoft Access* FORM
13 Comments4 Solutions197 ViewsLast Modified:
I have a form that I wrote an unload code for.

The code should do some checks before closing and closing may be cancelled.

Things are OK either I exit the form by the [x] control button or by a custom exit button.

However, when exiting the form by choosing "Design View" the following error occur.

Run-time error '2467'

The expression you entered refers to an object that is closed or doesn't exist.

Fortunately, I could regenerate the error with a tiny database that is attached.

Here is the form code:

Private Type Record
    stID As Long
    stName As String
    stAge As Long
End Type
Private Sub DoSomthing()
    Dim R As Record
    R.stID = Me.st_ID    ' The error occurs here and apparently it applies to the next two lines too. 
    R.stName = Me.st_Name
    R.stAge = Me.st_age
End Sub

Private Sub Form_Unload(Cancel As Integer)

    Call DoSomthing

End Sub

I could not find something specific to my case on the net.

Your help is appreciated.
Shadi Saleh

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 4 Answers and 13 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 4 Answers and 13 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