Solved Closing a form from the Form_Load event

In my tinkering with MS Access, I became quite frustrated with the Load event because it didn't behave as expected. I tried placing custom properties in the form's code module and setting their values when the form was opened, expecting to use these properties in my code.

However, I discovered that Access ignores these custom properties during the Load and Open events. It seems that, in Access's mind, these properties are not available to the VBA code during these events, which I found both strange and annoying.

After much experimentation, I realized I could create my own pseudo Load/Open event. Essentially, this involves writing a public function and calling it explicitly. Initially, it felt odd to create a function to emulate the Load or Open event in the way I wanted, but I soon understood this approach has its benefits.

The Load and Open events are intended to set up the form in a specific manner as designed by Access. If you deviate from this standard setup, it makes more sense to put your custom code in a separate function rather than in the Load or Open event or any other built-in event of the form.

So, what am I trying to convey here? I created a public event, which I named `fSetUp`. By doing it this way, I can set the custom properties to the desired values and then call the `fSetUp` routine, which has access to these custom properties.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom