Can I reference form data during the Unload event

Morten Lamoey 6 Reputation points

I have a form where I need to do some processing during the Unload event. In the Unload event, I then reference form data successfully 99.99% of the time, but every so often, I get an error indicating that the form may already be closed.

However, I have an error report that fires due to the above-mentioned error, where I list all the open forms, and the form where I'm running the unload event is still listed as open.

Are there any reason I should not reference a form during its Unload event?

Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
856 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. DBG 2,301 Reputation points

    Just FYI, earlier discussion on this topic is available at AWF.

  2. Ken Sheridan 2,756 Reputation points

    If you assign the data in the form's controls to a globally exposed array in the form's Current event procedure, and in its AfterUpdate event procedure you'll then be able to read data from the array even if the form has closed.

    What would you want to do if the form is at an empty new record? If you don't want to assign Nulls to the array, you'd need to make the assignment in the Current event procedure conditional on the NewRecord property being False.