Solved

Wait until a recordset is done loading

Posted on 2004-10-19
20
263 Views
Last Modified: 2006-11-17
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
0
Comment
Question by:rouxjean
  • 10
  • 9
20 Comments
 
LVL 19

Expert Comment

by:david251
Comment Utility
Try putting your code in the Form_open and then add subform.visible= true in the Form_load, since open occurs before load.

-David251
0
 
LVL 39

Expert Comment

by:stevbe
Comment Utility
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
0
 
LVL 39

Expert Comment

by:stevbe
Comment Utility
childInvDetail is the name of the subform control and not the name of the form that is embedded.

Steve
0
 

Author Comment

by:rouxjean
Comment Utility
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 !!
0
 
LVL 39

Expert Comment

by:stevbe
Comment Utility
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.Controls
    .txtID.ControlSource = "ID"
    .txtFirstName.ControlSource = "FirstName"
... etc.
End With

ENd Sub
0
 

Author Comment

by:rouxjean
Comment Utility
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....
0
 
LVL 39

Expert Comment

by:stevbe
Comment Utility
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
0
 

Author Comment

by:rouxjean
Comment Utility
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 ?
0
 
LVL 39

Expert Comment

by:stevbe
Comment Utility
do them all from the Load event of the main form, Access loads subforms before main forms.
0
 

Author Comment

by:rouxjean
Comment Utility
Nope that's what I was saying, i'll try this !
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:rouxjean
Comment Utility
Hum I tried like this :
Me.SubQuoteDetails.Form.Controls.Base_Price
and like this :
Me.SubQuoteDetails.Base_Price
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
0
 
LVL 39

Expert Comment

by:stevbe
Comment Utility
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
0
 

Author Comment

by:rouxjean
Comment Utility
SubQuoteDetails.....
0
 
LVL 39

Expert Comment

by:stevbe
Comment Utility
Do you mean that Intellisense did not display the controls or do you mean the code does not work?

Steve
0
 

Author Comment

by:rouxjean
Comment Utility
ctl.Name = SubQuoteDetails, this is what the msgbox displayed.
And this is what I used in those tries :
Me.SubQuoteDetails.Form.Controls.Base_Price.ControlSource
or
Me.SubQuoteDetails.Base_Price.ControlSource
Any idea ?
0
 
LVL 39

Accepted Solution

by:
stevbe earned 500 total points
Comment Utility
Me.SubQuoteDetails.Form.Controls("Base_Price").ControlSource
0
 

Author Comment

by:rouxjean
Comment Utility
That did the job thank you !
0
 

Author Comment

by:rouxjean
Comment Utility
Damn I can't use a with statement like this ? :
===========================
With Me.SubQuoteDetails.Form.Controls
    ("Qty").Locked = True
    ("Qty").ControlSource = "Qty"
End With
===========================
Is there a way to accomplish this ?
0
 
LVL 39

Expert Comment

by:stevbe
Comment Utility
you could try ...

===========================
With Me.SubQuoteDetails.Form.Controls
    !Qty.Locked = True
    !Qty.ControlSource = "Qty"
End With
===========================

Steve
0
 

Author Comment

by:rouxjean
Comment Utility
Nice, thanks again !
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now