MS Access: Error when form is unloaded by Design View
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 LongEnd TypePrivate 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_ageEnd SubPrivate Sub Form_Unload(Cancel As Integer) Call DoSomthingEnd Sub
What's the purpose of loading data into a User Type when unloading a form?