• Slow queries opening form (A2003)

    Author
    Topic
    #430926

    I have an unbound form that is processing mail merges (1 to Word and 1 to Outlook). As it loads it runs 2 SQL queries and feeds the results into 2 tables ready for the merge, counts the tables and shows the results in 2 text boxes.

    This takes several seconds. I would like the form to open before doing the queries so that the user is not left with the previous form, but I can’t find which event to tie the code to so that it runs after the form opens.

    David

    Viewing 0 reply threads
    Author
    Replies
    • #1007423

      Does it help if you insert a line

      Me.Repaint

      before the code that runs the queries?

      • #1007546

        Hi Hans

        No discernable difference. By the way, I should have said I was using the On Current event.

        David

        • #1007549

          Try putting the Me.Repaint line in the On Open event of the form.

          • #1007574

            That also does not appear to do anything. I tried following it in the On Open event with a MsgBox and it appeared … but not the form. There surely must be some point in the sequence of things where one can say that a form is visible.

            I’m going to try to put a timing delay in to see if that gets the form to appear.

            Regards

            David

            • #1007675

              Have you tried the OnLoad event of the form?

            • #1008430

              Hello Pat

              Sorry, On Load also doesn’t work. I have experimented with some code I found a long time ago on the MS website. It uses a timer to create a delay between opening the form and running the queries. I’ve found that the delay can be the minimum 1 millisecond (I think thats the unit) its sufficient just to have a delay.

              This surely can’t be the answer, but heck it works.

              Thanks again to you and Hans.

              David

    Viewing 0 reply threads
    Reply To: Slow queries opening form (A2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: