Results 1 to 4 of 4

Thread: DoEvents

  1. #1
    Join Date
    Sep 2003
    Location
    Hertfordshire, England
    Posts
    78

    Unanswered: DoEvents

    I have a form with two subforms. These subforms have records in a list and each subform has a field that counts records in the sub forms.

    I have a button on my form that when pressed runs many queries and bits of code. The first bit does a check that both of the count fields contain more than zero. The problem is that one of the sub forms count fields goes blank when I press my button so therefore it errors as it can't tell what the count is.

    I believe this is because I am trying to refer to the fields before it has had a chance to calculate the count.

    To resolve this I have put in a DoEvents function within a loop which does solve the problem most of the time:

    Code:
    Dim i As Integer
    
    For i = 1 To 10000
    
         DoEvents
    
    Next i
    The problem with this is that there is always a long delay. Sometimes not long enough but very rarely.

    Can you tell me, is there a way to use this DoEvents function in some kind of loop where it will just wrong as long as it needs?

    If that does not make sense let me know and I will try and re-explain it.

    Thank you

    Neil.
    Last edited by NeilA; 10-10-05 at 10:34.

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    interesting!
    i've never tried this, but maybe it's worth a thrash:

    do while nz(yourSubformCountField, -99) = -99
    doevents
    loop

    -99 is my guess at an "impossible" value. if -99 is a legitimate value try
    nz(yourSubformCountField, "#*/~?") = "#*/~?"
    or something else that cannot legitimately happen.

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Sep 2003
    Location
    Hertfordshire, England
    Posts
    78
    Thank you

    I will give that a thrash and let you know what happens.

    Neil

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    afterthought:

    do while isnull(theCountFieldTxtboxWhatever) then
    doevents
    loop

    is probably more general (but i still don't know if this scam will work)

    izy
    currently using SS 2008R2

Posting Permissions

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