Force Form to finish Loading before running Code

A

Alan

Sorry Folks ... Pulling my hair out here ... I have a for that loads and
after load I want it to un a query. Problem is that the query always launched
before the form has completed loading.

I have tried using the Form_Activate option as suggested in another post
amopngst a number of others

Is there an easy way to force the Form to load First
 
A

Alan

Dave

I want the query to run after the form has fully loaded. The query is a
simple import
 
K

Klatuu

Well, there is no event that fires when the form is fully loaded, so you may
need to trick it a bit by using the form's Timer event.
Set the Timer Interval property in design view to something small, maybe a
second or two. 2000 would be 2 seconds

Then in the Timer Event, run the query and set the Timer Interval to 0 so it
wont' run again in the current session.
 
A

Alan

Dave

Sorry for the delay getting back to you here...

I already use the Form Timer Event set to 1000 to provide a clock on the
form being presented. I am seeking a way of allowing the user to load the
initial form and continue to use the functions on it, while the import runs
in the background.

The import code contains a number of Do Events hoever the form wont load
fully first to allow the user to make use of some of the additional
functionality

Sorry I should have been more explicit first time round
 
S

Stuart McCall

Alan said:
Dave

Sorry for the delay getting back to you here...

I already use the Form Timer Event set to 1000 to provide a clock on the
form being presented. I am seeking a way of allowing the user to load the
initial form and continue to use the functions on it, while the import
runs
in the background.

The import code contains a number of Do Events hoever the form wont load
fully first to allow the user to make use of some of the additional
functionality

Sorry I should have been more explicit first time round

PMFJI but it sounds like your form may in fact be loaded, just not visible
yet (guessing). Try Me.Repaint
 
A

Alan

Stuart

Thanks for the update ... however did try that and it appears the query
takes over
 
S

Stuart McCall

Alan said:
Stuart

Thanks for the update ... however did try that and it appears the query
takes over

Ok, here's something to try.

Create a transparent command button on you form. Doesn't matter what you
call it. Set its caption property to &Dummy. Move the code that runs your
import into its Click event proc.

Now, make yourself an AutoExec macro if you don't already have one, and
enter two commands:
1 OpenForm to open your form
2 Sendkeys - Keystrokes=%D - Wait=Yes

A bit of a kludge I'm afraid, but it's worked for me in the past. The key to
this working is that the button is 'clicked' external to the form itself.

Hope it helps.

PS leave the Me.Repaint in there just in case (can't remember if it's
needed, but hey...)
 
A

Alan

Stuart

Wuld yu believe ... I have called the function MyForm.visible = True and the
B@#od& thing now works as expected.

Dont know why this should matter but it does and that seems good enough for me
--
Many Thanks for your help

Regards

Alan


Dave likewise ..... very much obliged for your time
 
K

Klatuu

There is no reason you could not perform the import in the same timer event.
For example, lets say you want the import to begin on the second tick. Use a
static variable in the event and base the execution of the import on that:

Private Sub Form_Timer()
Static intCtr As Inteter

If intCtr = 2 Then
Do your import here
End If

Other Stuff
intCtr = intCtr + 1
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top