Form does not show

dmcdivitt

Registered User.
Local time
Today, 05:44
Joined
Mar 12, 2009
Messages
28
A messy application I am now responsible for, was made mostly with macros and very little code. It's a huge, unnecessarily complex application with a vast number of forms. As time goes on, I rewrite and delete.

There is a form that was opened through a macro. In past when I converted the macro to code, the form would never show when opened. I had to leave the macro in place because I didn't have time to figure out why.

Now I must use code because other stuff is needed and I'm not going mess with macros. When the form is opened in code and does not show, if I press ESC it appears. So, in code, I tried using sendkeys and ESC. That does work most of the time. Rather than doing this fifty times in a loop to insure the form opens, I would like to see why it does not show without ESC.

I made a popup debug form with a timer to show screen.activeform.name and screen.activeform.activecontrol.name. The form is opening, and if I hit tab, it walks through all the textboxes and lists, even though the form is not visible, but as soon as I hit ESC it becomes visible. It also has a tab control with a bunch of stuff on each page. I am thinking there's bad SQL or something not found somewhere, causing an error condition, and ESC is canceling the error, but I see no error. The form opening process from a macro is different than when done with code.

The problem is seen with all versions of Microsoft Access from 2000 through 2016.

Please comment if you have an idea. Thanks
 
What happens if you simply browse to the form and open it from the database window?
 
Unable to open from the database window since preparation must be done. But you have given me an idea. I can do the prep in code, then click on the form in the database window to see what happens. It probably will work, which won't help me any.
 
Okay that's interesting - so it's expecting information from other forms ?
 
The form is bound to a recordset and all the fields are bound. It uses a bunch of text boxes, hidden on the log in form sitting at the bottom of the zorder. The sql has references to that form in the where clause. When the form opens it reads the correct record.
 
What exactly is the macro code doing - can you list its actions?
It makes no sense that a macro would be any different to a VBA call, but Access can work in mysterious ways...
 
It opens eight append queries, places the key to look up on the log in form so it can be referenced, opens the form, sets a bunch of values on the form, then runs a couple more update queries.

When screwing with this in past I reduced the macro to just opening the form. The form would show when opened through a macro as a user initiated event, but only that way. Not code. If I put the sendkeys ESC in there, then it will show.
 
And what are the open form options in the macro?

I bet they turn warnings off in the macro before running the append queries as well...

I'd put money on this being a dialog that you can't see and are dismissing by pressing ESC.
 
This is what I think as well. Yes, warnings are turned off.

I did experiment a bit following your suggestion. A form has a list. Double-clicking an item in the list opens the form I'm having an issue with. Before double-clicking I did F11 to open the database window. My debug form was off to the side. I then double-clicked to open the problem form. It did not show. And the interface was locked. I was unable to click on anything. But if I kept pressing tab, the activecontrol name shown in the debug window kept changing. When I hit ESC the form showed and the interface was no longer frozen.
 
I would say there is some error on the form that is causing it to bring up an dialog or message box, that for some reason isn't visible.

I would convert the append query bits of the macro to vba. Get rid of everything else especially the warnings off / on bobbins. Use the VBA to run the queries, and pop a message box up when they are done, next in code - call the macro to open the form.

I'd bet something in the macro is failing, but because warnings are off you're getting a hidden error box.
 
Last edited:
I think turning warnings on will be what fixes it. I didn't think of that.
 

Users who are viewing this thread

Back
Top Bottom