Finish Loading a Form Before Executing Other Subroutines
Hi All,
I have two forms, the first calls the second when the start button is clicked using:CFT_Progress.Show vbModal, CFT_MainThe form will start a subroutine to write to Attachmate when loaded with the values from the first form:Private Sub Form_Load()
CFTCSS_Activate_Session
End SubMy problem is that the second form does not display on the screen until after all the code in the subroutine has been completed. I need the second form to display before the code is executed.
Any ideas on how i do it?
Thanks,
Gareth.
# 1 Re: Finish Loading a Form Before Executing Other Subroutines
If I understand you correctly, this should do the trick:
Private Sub Form_Load()
Me.Show vbModal, CFT_Main
CFTCSS_Activate_Session
End Sub
Therefore, in the first form you could use Show without any parameters, or Load CFT_Progress should work too.
# 2 Re: Finish Loading a Form Before Executing Other Subroutines
Hi Mate,
Thanks for the reply. Ill try this out when i get to work tomorrow. I was considering adding all the CFTCSS_Activate_Session code to a module, calling the module from CFT_Main and then calling CFT_Progress from the module but hopefully this will save all the messing about.
Gareth.
# 3 Re: Finish Loading a Form Before Executing Other Subroutines
Depending on the situation, adding a Public Sub to the form can simplify matters.
# 4 Re: Finish Loading a Form Before Executing Other Subroutines
Or, create a module, and start in Sub Main() before any forms load.
# 5 Re: Finish Loading a Form Before Executing Other Subroutines
If I understand you correctly, this should do the trick:
Private Sub Form_Load()
Me.Show vbModal, CFT_Main
CFTCSS_Activate_Session
End Sub
Therefore, in the first form you could use Show without any parameters, or Load CFT_Progress should work too.I tried this method and it didnt change the way the program ran. When i get chance ill try the CFT_Main > Module > CFT_Progress method.
Thanks,
Gareth.
# 6 Re: Finish Loading a Form Before Executing Other Subroutines
I know this is not the best way to do it, however, try adding a timer to the modal form with a 500 interval. Put your CFTCSS_Activate_Session in the timer elapsed event. Also in the event, disable the timer. That way your form will show, the timer will fire, you disable the timer, then run your routine.
# 7 Re: Finish Loading a Form Before Executing Other Subroutines
Try adding the Refresh method:
Private Sub Form_Load()
Me.Show vbModal, CFT_Main
Me.Refresh
CFTCSS_Activate_Session
End SubThis works in every form in which I've used it, so if your form still doen't show properly, then please post more of the relevant code so we can see what's wrong.