Hidden Form in Access Closes Unexpectedly

Today I solved a nagging problem with an Access database, so I’ll share the solution here, in case it helps someone else.

In an Access database that I built, there is a Login form, where the users select their name from a drop down list.

accesslogoform03

Then, when they click OK, the Login form is hidden, and a data entry form opens.

accesslogoform01

The Login form stays open in the background, and other forms and queries can hook into the ID for the selected user name.

Hidden Form Closes Automatically

Everything works well, except when I open the data entry form in design view, to make changes. Then, without warning, the Login form closes. The user ID isn’t available to any of the other forms, and I have to go back to the Login, and select a name again.

This is more of an annoyance than a serious problem, but I wanted to figure out why it was happening.

I put breakpoints all through the code, and stepped through, to find out when the Login form closed. Was there something in the code that was making it shut down?  Nothing turned up in the code, so I was left scratching my head.

The SubForm Did It

Finally, it dawned on me that the Login form and the Data Entry form both used the same subform – it holds the logo, at the top left.

accesslogoform04 

The Logo subform saves space in the database, because the image is only in there once. It also makes it easy to make global changes, if the logo or heading text changes.

When I opened the data entry form in Design View, the Logo subform was also in Design View.

accesslogoform02

The hidden Login form closed because it couldn’t show the Logo in form view, while the Logo was in Design View on another form.

Fixing the Problem

To solve the problem, I created a copy of the Logo form, and named it Logo2. On the Login Form, I changed the subform to Logo2. Now, there is no conflict when I open the Data Entry form in Design View, so the hidden Login form stays open.

Maybe this will help you, if you have Access forms that mysteriously close, without being told to.

__________

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.