469,645 Members | 1,971 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

Unbound Form "AutoLoad" Event Issue

I have been asked to develop an application in Access for work. This application must have a simple user interface because the folks using it are not "database people" - their words, not mine.

One of the "screens" they want to see will display a progress bar. I created the "screen" in a form. I do not currently have it bound to any data because it is not intended to display any records. It's sole purpose is to show the progress bar (and some text describing what it's doing) while visual basic does some magic in the background.

Here is the issue I'm having. If I put my code into the onclick event of a button, everything works fine - exactly how I want it to.

If I put my code into the forms onload event, the code executes prior to the form being displayed - as expected, right? But we want to see the progress bar change as VBA does its deal. Because the form hasn't been displayed yet, you just wait until VBA is done, and then get the form displayed showing a full progress bar and text indicating that VBA is finished with its job. So onload is definitely not where I want the code. - Please note that the form actually hasn't displayed yet, so repainting the form won't help here.

But if I put the code into the forms onactivate event, nothing happens. The form is displayed, but the code never executes.

I understand that onload fires prior to the display of the form. onactivate supposedly fires after the form is displayed (and I guess it can fire after that too depending upon focus, etc.). But even if I put some very simple code in the onactivate event - like msgbox ("Hi there.") - , nothing happens.

I thought maybe the form had to have a record source for onactivate to fire, so I've tried actually binding the form to a record source, but it didn't help. Then I tried actually displaying a record from that record source on the form, but it didn't help. I simply can't seem to get the onactivate event to fire.

What am I missing? I'm sure it is something rediculously simple and I'll go ahead and apologize for being a big dummy. But I'm stumped and would really appreciate some help.

For now, I'm just going to make them click the button to get it all started until I get this thing figured out. Thanks in advance for helping to push back my ignorance!
Oct 12 '08 #1
4 2507
2,653 Expert 2GB
Hello, Robert.

I suppose you should put your code in Timer event handler having set TimerInterval to let us say minimal value = 1ms.

Form will not be visible while all the following events are being handled.

Got focus

Oct 12 '08 #2
Hello Fish!

You know, it's amazing how we get caught up in "what we know" about how things work. I had originally dismissed the timer function because I was SURE that once I put something in the ontimer event, that it would continue to execute at the specified interval until the cows came home or the form was closed. I just assumed that setting the timer interval to zero would just repeatedly fire the code.

But your solution was perfect! I set the form's timer interval property to 50. It displays the form perfectly, then 50 ms later fires the code. The first line of the code sets the timer interval back to zero. And no matter how long the box stays open, the code only fires one time!

Outstanding. And I didn't even have to release my version with the command button!

I wonder how many other functions and events I "think" I know....

Thanks again!
Oct 12 '08 #3
2,653 Expert 2GB
You are welcome.
Good luck.
Oct 12 '08 #4
32,203 Expert Mod 16PB
Nice one Fish.

I was intrigued, and did some testing. Open AND Load were both executed before the form was even visible. Yours is a clever solution to the problem :)
Oct 12 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.