Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Mar 2007
    Location
    Wikltshire UK
    Posts
    152
    Thanks
    2
    Thanked 0 Times in 0 Posts

    DoEvents Sticking in Loop?? (Access 2007)

    Wondering if anyone knows why Access 2007 in VBA sticks on the code below and then after a while (i.e. Not streight away) exits the loop once the Query is closed. I use it to hold the code while I Visually check the contents of the Query and delete duplicates before continuing processing. It worked fine in Access 2000. It also Crashed Access last time I ran it??

    DoCmd.OpenQuery "MatchedDup"
    Do
    PayCheck = SysCmd(acSysCmdGetObjectState, acQuery, "MatchedDup")
    DoEvents
    Loop While PayCheck = 1

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DoEvents Sticking in Loop?? (Access 2007)

    I apologize for the lack of replies. I cannot find any mention of this problem, and I don't have Access 2007 myself yet, so I cannot experiment.

  3. #3
    2 Star Lounger
    Join Date
    Mar 2007
    Location
    Wikltshire UK
    Posts
    152
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: DoEvents Sticking in Loop?? (Access 2007)

    No Worries Hans. I've checked the net myself and it could be something to do with having a duo processor, as it takes the oppertunity to process Idle events during a Doevents??
    Any one else got any comments??

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: DoEvents Sticking in Loop?? (Access 2007)

    My understanding is that you want to pause the code until the query is closed.

    Another way to achieve the same result is build a continuous form based on the query, and display that form rather than the query.

    If you open the form in dialog mode, code execution will be stopped until the form is closed.

    DoCmd.OpenForm stDocName, acNormal, , , , acDialog
    Regards
    John



  5. #5
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: DoEvents Sticking in Loop?? (Access 2007)

    Further to my previous post, I have just tested your code on my 2007 machine, and I worked fine!
    I am using a Centrino Duo HP laptop.
    Regards
    John



  6. #6
    2 Star Lounger
    Join Date
    Mar 2007
    Location
    Wikltshire UK
    Posts
    152
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: DoEvents Sticking in Loop?? (Access 2007)

    Thanks John. I'll give that a go Monday.

Posting Permissions

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