order of forms loading...

B

Brad Pears

I have an application where I am loading a form that contains three
subforms. One of these subforms is actually a "container" where I am
dynamically loading other forms into it depending on certain options chosen.
I am using the .sourceobject property to do this.

It has not been working too badly but recently I have run into some issues.
In one of the subforms, I am populating a hidden field with the value of a
textbox from one of the other forms - which I expected to already have been
loaded. What I am finding is that this form had not loaded it's objects yet
and as a result the value I wanted did not exist - hence it was "null".

What I am wondering is if someone can tell me in what order Access loads
forms/subforms etc.. and is there any way to force a particular form to
ALWAYS load first....



Thanks,

Brad
 
K

Ken Snell \(MVP\)

ACCESS will load subforms first, then the main form. What I do to handle the
setting of properties and values in subforms in these cases is to not have a
SourceObject for the subforms initially, then let the main form assign a
SourceObject to the subforms using the main form's Load event or some other
action that the user causes to occur.
 
A

Arvin Meyer [MVP]

Normally, you wouldn't worry about the order of the forms loading. Simply
add a delay in the subform's load event. and have the it requery. Here's
some code that you can use to add a delay. A half second should be more than
enough:

Public Function Delay(dblInterval As Double)
'--------------------------------------------------------------------
' Name: Delay
' Purpose: Generic delay code
' Inputs: dblInterval As Double
' Author: Arvin Meyer
' Date: January 2, 1999
' Comment:
'--------------------------------------------------------------------
On Error GoTo Err_Delay
Dim Timer1 As Double
Dim Timer2 As Double

Timer1 = Timer()
Do Until Timer2 >= Timer1 + dblInterval
DoEvents
Timer2 = Timer()
Loop

Exit_Delay:
Exit Function

Err_Delay:
Select Case Err

Case Else
MsgBox Err.Description
Resume Exit_Delay
End Select

End Function

Use it like:

Delay (0.5)
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
B

Brad Pears

That sounds good but the problem is that by using a delay it appears that it
is just holding up the loading of this other subform that I really need to
be present as well! I need to be able to specify somehow what form to load
first...

I tried the delay and no matter what I set it to, the other form does not
load until AFTER this one, so it is defeating the purpose...

Thanks anyway though.. I will use your delay function for other things!

Brad
 
B

Brad Pears

I will try that - but is there no way at all to specify what forms to load
in what order?

Thanks, Brad
 
K

Ken Snell \(MVP\)

No, you have no control over the order of the forms loading. So that is why
I control the "assignment" of the SourceObject by code, as that lets you
control the process.
 
U

UpRider

Maybe you could check for "isloaded" and loop the delay until the desired
form is present....
 

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