rouxjean
asked on
Wait until a recordset is done loading
Hi !
I have this header form that has a recordsource set on its onload event (a query that may be long to run). I also have a subform that is based on a table and therefore is way faster to run. So the details appears like 3 seconds before the header. I'd like to avoid this this ? Maybe wait until the query of the header is finished ?
How could I proceed ? (code needed as usual...)
Thanks
I have this header form that has a recordsource set on its onload event (a query that may be long to run). I also have a subform that is based on a table and therefore is way faster to run. So the details appears like 3 seconds before the header. I'd like to avoid this this ? Maybe wait until the query of the header is finished ?
How could I proceed ? (code needed as usual...)
Thanks
Subforms do in fact load before their parent forms so to follow along with David251 ... this code goes in events for the parent form.
Private Sub Form_Open(Cancel As Integer)
Me.childInvDetail.Visible = False
End Sub
Private Sub Form_Load()
Me.childInvDetail.Visible = True
End Sub
Steve
Private Sub Form_Open(Cancel As Integer)
Me.childInvDetail.Visible = False
End Sub
Private Sub Form_Load()
Me.childInvDetail.Visible = True
End Sub
Steve
childInvDetail is the name of the subform control and not the name of the form that is embedded.
Steve
Steve
ASKER
So subform would be invisible until header query is done. What I want is all the layout to be displayed on form load and all the data to be filled in at once !!
then you will need to bind the controls on the subform in the main form's load event
Private SUb Form_Load()
With Me.childDetail.Form.Contro ls
.txtID.ControlSource = "ID"
.txtFirstName.ControlSourc e = "FirstName"
... etc.
End With
ENd Sub
Private SUb Form_Load()
With Me.childDetail.Form.Contro
.txtID.ControlSource = "ID"
.txtFirstName.ControlSourc
... etc.
End With
ENd Sub
ASKER
stevbe: i'm already doing this for both the form & subform...but still, the subform is loaded first because, I think, it is based on a small table rather than a large query for the header....
are you doing it in the parent form's load event? Using the load event *should* make sure that the recordset is loaded before you start assigning Control Sources
Steve
Steve
ASKER
stevbe: well, i'm doing it in the form load event for the texboxes in the form, and in the subform load event for the textboxes in the subform. Is that the cause, what should I do ?
do them all from the Load event of the main form, Access loads subforms before main forms.
ASKER
Nope that's what I was saying, i'll try this !
ASKER
Hum I tried like this :
Me.SubQuoteDetails.Form.Co ntrols.Bas e_Price
and like this :
Me.SubQuoteDetails.Base_Pr ice
Doesn't find the texboxes (of course I added the controlsource after...) !!!!
SubQuoteDetails is the name of the subform component and Base_Price is the name of the texbox
Me.SubQuoteDetails.Form.Co
and like this :
Me.SubQuoteDetails.Base_Pr
Doesn't find the texboxes (of course I added the controlsource after...) !!!!
SubQuoteDetails is the name of the subform component and Base_Price is the name of the texbox
use this code on the main form to make sure you have the correct subform control name ...
Private Sub Form_Load()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acSubform Then
MsgBox "this is the name to use: " & ctl.Name
End If
Next
End Sub
Private Sub Form_Load()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acSubform Then
MsgBox "this is the name to use: " & ctl.Name
End If
Next
End Sub
ASKER
SubQuoteDetails.....
Do you mean that Intellisense did not display the controls or do you mean the code does not work?
Steve
Steve
ASKER
ctl.Name = SubQuoteDetails, this is what the msgbox displayed.
And this is what I used in those tries :
Me.SubQuoteDetails.Form.Co ntrols.Bas e_Price.Co ntrolSourc e
or
Me.SubQuoteDetails.Base_Pr ice.Contro lSource
Any idea ?
And this is what I used in those tries :
Me.SubQuoteDetails.Form.Co
or
Me.SubQuoteDetails.Base_Pr
Any idea ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That did the job thank you !
ASKER
Damn I can't use a with statement like this ? :
========================== =
With Me.SubQuoteDetails.Form.Co ntrols
("Qty").Locked = True
("Qty").ControlSource = "Qty"
End With
========================== =
Is there a way to accomplish this ?
==========================
With Me.SubQuoteDetails.Form.Co
("Qty").Locked = True
("Qty").ControlSource = "Qty"
End With
==========================
Is there a way to accomplish this ?
you could try ...
========================== =
With Me.SubQuoteDetails.Form.Co ntrols
!Qty.Locked = True
!Qty.ControlSource = "Qty"
End With
========================== =
Steve
==========================
With Me.SubQuoteDetails.Form.Co
!Qty.Locked = True
!Qty.ControlSource = "Qty"
End With
==========================
Steve
ASKER
Nice, thanks again !
-David251