Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2004
    Posts
    115

    Unanswered: Need your opinion before changing my function

    I really like my current function (That Highlights the current lines) in the attached sample DB. Because this function runs at the OnCurrent event instead of OnClick.
    So if I use the keyboard, it still gets highlighted

    However, my form has 2 sub forms (the 2 sub forms are linked) and when the first sub form get the focus, the second sub form automatically gets refreshed.

    Here is my problem
    Very often, MsAcces will freeze when the first sub form get the focus. Because the computer tries to run the same function for both sub forms at the same time.
    (This happens only if the second sub form has any information)

    I was thinking, maybe I should change the function to run at the OnKeyUp and to the OnClick.
    The idea is that the second subform will not run the function until I click on it.
    the problem with this way, I will have to add this function to each field individually.
    However, before I will change all my forms, I would like to have you opinion.

    Any idea?

    Thanks
    Tom
    Attached Files Attached Files

  2. #2
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    Ah, timing - sometimes it is too fast for itself.

    I had a similar problem sending a series of reports that were selected in a list box to the snapshot viewer. Some of the reports were one pagers and it could crash Access because the code was executing too fast for the Snapshot viewer to keep up (the code was calling for the report to be closed before the viewer was done grabbing the data).

    Here's what I did and maybe it will work for you. Right before the command line that tells the second sub form to refresh, make the computer pause (I have it count to 200 using an empty loop). Sounds crude, but it solved the problem and the time it takes for a P-III to count to 200 is not noticed by the average user.

    Hope this helps!
    have fun!

    Todd S.
    click to email


    Independent Development Consultant
    Biz db & reports - SQL, Access, Crystal, Seradex and more
    Small, custom, unique programs - Office, VBA, .NET


    _________________________________________________
    Favorite message from Windows:
    There was an error displaying the previous error message

    Sadly, there was no error number to look up ...

  3. #3
    Join Date
    Jan 2004
    Posts
    115
    Yes, this was very helpful

    Can you please copy and paste the few lines that Pauses the system?
    Thanks
    Tom

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Here ... You can see the one I developed ...

    Code:
    Public Function LoadingDelay(Optional ByVal DisplayDelayForm As Boolean = False)
        Dim StartTime As Date
        
        DoCmd.Hourglass True
        If DisplayDelayForm Then DoCmd.OpenForm "Loading"
        StartTime = Now
        Do While True
            DoEvents
            If DateDiff("s", StartTime, Now) > 5 Then Exit Do
        Loop
        If DisplayDelayForm Then DoCmd.Close acForm, "Loading"
        DoCmd.Hourglass False
    End Function
    P.S. - The "Loading" form is a form with the menu buttons disabled displaying the text: LOADING FORM PLEASE BE PATIENT ..."
    Back to Access ... ADO is not the way to go for speed ...

  5. #5
    Join Date
    Jan 2004
    Posts
    115
    Thanks

    Do you a code that actually pauses the running function, not just opens a form?

    Thanks

  6. #6
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    There are many ways to make the computer wait;

    The one shown by M Owen allows you to specify the actual time to wait (in the example, it waits 5 seconds).

    You can use the Timer function as well, which gives you the number of second since midnight on the internal clock. You can specify your wait time down to 1/100th of a second:
    Code:
    Dim EndTime As Single
    Dim DelayTime As Single
    
    DelayTime = 1.5  ' The time to wait in seconds
    EndTime = Timer + DelayTime
    Do
    Loop Until Timer > EndTime
    This method will not work properly if your delay passes midnight, however. I believe that M Owen's will!

    Another method, the one I used in the situation I mentioned earlier was this:
    Code:
    Dim iC As Integer
    For iC = 1 to 200
    Next
    The actual time of the delay is dependent on the speed and resources available of the PC, but either way, it provides the split second the viewer needs to release the report before the next line of code tries to close the report.

    So, to answer your question, insert the "empty loop" before the command line that refreshes the second sub form.
    have fun!

    Todd S.
    click to email


    Independent Development Consultant
    Biz db & reports - SQL, Access, Crystal, Seradex and more
    Small, custom, unique programs - Office, VBA, .NET


    _________________________________________________
    Favorite message from Windows:
    There was an error displaying the previous error message

    Sadly, there was no error number to look up ...

Posting Permissions

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