Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Join Date
    Feb 2007
    Posts
    10

    Unanswered: docmd.hourglass bug?

    Hello,

    I've created a form that has record selectors on it. I want the cursor to change to an hour glass when the user clicks on any record selector, then process some code and then have the cursor return back to normal after the code is completed. To make it simple, I created a loop to reproduce the same problem. Below is the code I'm using for the form on_click event. If i ctrl-break during the looping process I can see the hour glass.

    I read somewhere about possibly using a transparent button, but that wouldn't work because the user needs to click on the record selector.

    Private Sub Form_Click()
    Dim i As Long
    DoCmd.hourGlass (True)
    For i = 1 To 100000
    Debug.Print i
    Next i
    DoCmd.hourGlass (False)
    End Sub

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    That's not a "bug", it's a "feature". Normally I'd say to put the

    DoCmd.Hourglass False

    in an error trap, so that if an error occurs the pointer is changed back. Control-Break stops code execution, so of course it won't get to the error trap and the pointer stays where you set it. I believe you can disable Control-Break in Tools/Startup.
    Paul

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    His problem would be that the hourglass doesn't appear at all, not that the hourglass stays on when CTRL-Break is pressed.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    I read it otherwise:

    Quote Originally Posted by etaktaf
    If i ctrl-break during the looping process I can see the hour glass.
    and testing bears that out.
    Paul

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    We all know that if you CTRL-Break code that starts off with DoCmd.Hourglass False the hourglass will stay on.

    When I run the code, the hourglass doesn't appear UNTIL I hit CTRL-Break. I still think what he's trying to say is that he wants the hourglass to actually work and not look like the application has hung.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    I suspect you mean code that starts out with DoCmd.Hourglass True, as it's True that turns it on, not False. Presuming so, I certainly agree, as I said as much in my first post.

    I'm surprised at your test result, as when I paste that code behind a button the hourglass appears instantly when I click the button, as I would expect.

    I guess we need the OP to clarify the issue they're having.
    Paul

  7. #7
    Join Date
    Feb 2007
    Posts
    10
    Sorry if I confused some of you in my original post. I meant to say that the hourglass never comes on once the hour glass to set to true. Feel free to test out that code I have pasted in the original message. The only way I could see the hour glass was to ctrl-break the process.

    I can get the hour glass to work with other click events like with a command button, but for some reason the form click event doesn't work for me.
    Last edited by etaktaf; 12-13-07 at 23:18.

  8. #8
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    I guess I owe apologies all around then, but I'm confused, as my testing had the opposite result, as noted earlier. Perhaps it's because I used a button rather than the form's click event.
    Paul

  9. #9
    Join Date
    Feb 2007
    Posts
    10
    Hey Pbaldy,

    Can you try the form on click event? I'm curious to see if you get the same thing.

    Thanks.

  10. #10
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    I have and I do get the same behavior you experienced. My bad for not testing under your exact scenario. I can't see why the code would not behave properly in that event, but I will poke around.
    Paul

  11. #11
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Yes, I meant starts with DoCmd.Hourglass True, my bad there

    And yes, the hourglass doesn't seem to work with a few things... It didn't work for me when I tried it on clicking a label either. I'll have to poke around some too... in order to get to the bottom of this. Seems very much like another Access bug.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  12. #12
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    re

    2 possibilities
    1. What if you put the do.hourglass in an other sub
    Waht i'm getting at is that the function didn't exit his routine jet and wont be triggerd till it ends for example

    Form_click
    Set_MouseWait (True)

    For loop Calculate somthin
    next

    err.handler
    Set_MouseWait(False)
    end sub

    Public Sub Set_MouseWait (bpState as bool)

    If bpState = True then
    do.mouse= vbhourglass
    else
    do.mouse= vbNormal
    endif

    end sub

    2. Other thing is that the mouse is set but you don't see it move the mouse (make a circle or zigzag it its a refresh problem, Try DoEvents in the loop or after setting the hourglass)

  13. #13
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    I tried DoEvents, Repaint and Echo True in the code, none of them helped.
    I tried using another function/subroutine to put the DoCmd.Hourglass into. It didn't help either.
    I tried turning on the Hourglass with a macro instead of code. It didn't help.
    I even tried moving the "hourglass on" operation into another form's On Open event procedure, then tried opening that form instead of using the DoCmd.Hourglass True and the hourglass still didn't show until the entire loop in the original event procedure was completed. Seems the only thing that turns the hourglass on is when the event procedure has completed, which defeats the purpose of having it

    Modal "Please Wait" form anyone? lol
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  14. #14
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Red face

    Quote Originally Posted by StarTrekker
    I tried DoEvents, Repaint and Echo True in the code, none of them helped.
    I tried using another function/subroutine to put the DoCmd.Hourglass into. It didn't help either.
    I tried turning on the Hourglass with a macro instead of code. It didn't help.
    I even tried moving the "hourglass on" operation into another form's On Open event procedure, then tried opening that form instead of using the DoCmd.Hourglass True and the hourglass still didn't show until the entire loop in the original event procedure was completed. Seems the only thing that turns the hourglass on is when the event procedure has completed, which defeats the purpose of having it

    Modal "Please Wait" form anyone? lol
    Have you tried it with an other state like Nodrop
    Have'nt got Acces here so cant test it my self

    Greetz and
    don't beat your keyboard up, he can't help it :-)

  15. #15
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    "Seems the only thing that turns the hourglass on is when the event procedure has completed"

    ...not quite.

    try adding after the hourglass line:
    If MsgBox("Might take some time to complete - OK to continue?", vbQuestion + vbOKCancel, "Long process") = vbCancel Then Exit Sub

    not surprised huh?

    so now move it before the hourglass line!!!
    troooooooly bizarre.

    BTW: identical behaviour from
    screen.mousepointer = 11

    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
  •