Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2011
    Posts
    27

    Unanswered: Track Subform Load Times

    I've got a slow form with too many subforms. Is there a simple way to track the load times of each subform?

    I'm not sure in which Event and in which form(s) I should be putting a Timer and how to get the loaded subform name.

    Any help is appreciated. Thanks!

  2. #2
    Join Date
    Oct 2009
    Posts
    340
    if the subforms are based on queries; then with the main form open, but shrunk out of the way; manually open those queries yourself and note how long they take......
    www CahabaData com

  3. #3
    Join Date
    Jan 2011
    Posts
    27
    Does having the main form open affect the running queries? Also, I was hoping to have exact times and order. Some forms are multiple forms, some are regular, and they all use each other as filters. I'm curious to see how these factors affect performance as well. I'll have to do that if I can't find a way with VBA. Thanks!

  4. #4
    Join Date
    Oct 2009
    Posts
    340
    no having the main form open will not affect a query time.

    the reason I say to have it open - is because these queries may be looking to the main form for a parameter....if they don't then you would need this form open....but in either case it will not affect it.

    you need to see how long it takes for a query(s) to run - that's the essence of the time consideration.
    www CahabaData com

  5. #5
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    The succession of events when a form opens is:

    Open → Load → Resize → Activate → Current

    You need to acquire some start time on the Open event, acquire an end time on the Current event, then a substraction will yield the info you're looking for.

    1. Create an independant module and paste this in its Declarations section:
    Code:
    Public Declare Function GetTickCount Lib "kernel32" () As Long
    GetTickCount calls an internal clock of the Windows operating system and returns a number of milliseconds as a Long value.

    2. In the Declarations section of the class module of a form you want to monitor the opening time, paste this line:
    Code:
    Private lngTStart As Long
    3. Create the event handler for the Open event for the form, like this:
    Code:
    Private Sub Form_Open(Cancel As Integer)
      
        lngTStart = GetTickCount
    
    End Sub
    Note: If there already is a Sub Form_Open, simply add the line at the beginning of it.

    4. Create the event handler for the Current event for the form, like this:
    Code:
    Private Sub Form_Current()
    
        Debug.Print "Form: " & Me.Name & " loaded in: " & GetTickCount - lngTStart & " milliseconds."
        
    End Sub
    Note: If there already is a Sub Form_Current, simply add the line at the end of it.

    When the form is open then a line such as the following is printed in the immediate windows:
    Form: Frm_Measures_M_Combo loaded in: 63 milliseconds.
    If you prefer to have the information in a message bos, replace the line in the Form_Current procedure with:
    Code:
        MsgBox "Form: " & Me.Name & " loaded in: " & GetTickCount - lngTStart & " milliseconds.", vbInformation, "Form loading time"
    Have a nice day!

  6. #6
    Join Date
    Jan 2011
    Posts
    27
    NTC, I haven't had too many forms passing parameters, but that will save me some frustration one day.

    Sinndho, that's what I was looking for!

    Thanks both of you!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •