Form Load

G

Greg Snidow

Greetings all. I am using Access 2003. I have a switchboard form that has a
command button, cmdOpenSearchPopup, that opens a popup, frmSearchPopup.
frmSearchPopup has several unbound combos to filter for the search, then a
command button, cmdSearch, that opens the form frmJobInfo. My problem is
that frmJobInfo has a tab control with many tabs, and it takes about 6
seconds to load. Once it is loaded, however, a requery only takes about 1.5
seconds. Is there a way to load frmJobInfo in the background, invisible to
users, so it can be loading as they are entering in search criteria on
frmSearchPopup? I tried putting DoCmd.openform "frmJobInfo" as the last line
of cmdOpenSearachPopup, but I do not want the form to be seen until the users
hits the search button on the search popup. Maybe this is not possible?
Thank you for your time and help.
 
R

Randy Wayne

You can open your form as Hidden:

DoCmd.OpenForm "frmJobInfo", , , , , acHidden

then, when you want the user to see it:

Forms!frmJobInfo.Visible = True


To be safe, you can add a function that checks to see if the form is
actually open. Below is some addition code a really great MVP posted in the
past, but I don't have their name to give them credit:

Public Function IsOpen(ByVal strFormName As String) As Boolean
'Returns True if specified form is open in Form view

Const conDesignView = 0
Const conObjStateClosed = 0

IsOpen = False
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> _
conObjStateClosed Then

If Forms(strFormName).CurrentView <> conDesignView Then
IsOpen = True
End If
End If

End Function



To use this:

If IsOpen("frmJobInfo") Then
Forms!frmJobInfo.Visible = True
Else
'Do nothing...
End If

Let me know if this helps

Randy
 
G

Greg Snidow

Randy, thanks for your help. Your suggestion works as it should, by opening
the form in the background. The problem is that while frmJobInfo is loading
frmSearchPopup is not fully loaded. Its almost as if it waits until
frmJobInfo is loaded before the popup is useable. Any ideas?
 
R

Randy Wayne

Everyone struggles with the order and the timing of events. You will need to
experiment with both but I have found that inserting some strategic "delays"
often helps.

Below is a delay function:

Public Function DelayTime(PauseTime As Double)

'Used to slow the program down and allow for screen updating or
'other processes to catch up...

Dim start
'PauseTime = 4 ' Set duration.
start = Timer ' Set start time.
Do While Timer < start + PauseTime
DoEvents ' Yield to other processes.
Loop

End Function

Insert this is a General Module and then you can call it from any form (or
report) module that you need. In the argument insert the number of seconds
you want to delay Example:
DelayTime(2) will slow the loading down for 2 seconds; DelayTime (.5) will
delay for half second, etc.

By delaying the loading process you allow events to complete before the next
one starts, which often solves issues like what you are discribing.

One last suggestion:

If you use the form "frmJobInfo" often then I would load the form as Hidden
when the client first opens your Access Program. In fact, if you have other
forms that are used often you can give the users a perceived speed boost by
loading the common forms when the program launchs as hidden and them change
the code that "Opens" the forms to simple make them visible.
(Forms!frmYourFormName.Visible = True). Conversely, instead of closing the
form, simply hide it (Forms!frmYourFormName.Visible = False) unless you have
some reason to close the form.

Remember, if you have set a form to be Modal, it is best to turn modal on
and off at the same time (Forms!frmYourFormName.Modal= True) (or False) along
with the code to hide and show the form.

Finally, If you do decide to perform the form opening process at the launch
of your program, I would recommend a "Slash" form to load first to let the
user know something is happening. (Open Adobe Reader or MS Word and note the
splash that appears will various processes load).

By using delays, Splashes, and opening forms as Hidden, I think you can
solve your problem.

Let me know if this helps.

Randy
 
G

Greg Snidow

Thanks Randy. You are right about the order of events affecting the timing
of things. It is frustrating, but I found that I could make it a little
faster by changing the order of events. I think your suggestion of having
the form load at startup will help me the most, I never thought of that. I
am using an ADP, and I do not know how to use functions housed on our server
yet, so I will have to experiment with that. Thank you so much for taking
the time to consider my dilemma
 

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