Force Form to finish Loading before running Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Dave

I want the query to run after the form has fully loaded. The query is a
simple import
 
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.
 
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
 
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
 
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...)
 
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
 
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
 
Back
Top