Results 1 to 8 of 8
  1. #1
    Old Goat is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    5

    Using Hyperlink click bypasses OnUpdate event of other controls

    I have been tasked to replace command buttons in an Access 2003 application with label controls with a space in the hyperlink property to enable them as hyperlinks.



    The problem is that our application has a lot of code that is written assuming the AfterUpdate event fires on a text box, for instance, before the hyperlink is clicked.

    The OLD application used command buttons, and when clicked, the AfterUpdate event of the text box control fired before the command button code. When using a hyperlink, it does not fire at all.

    Is there any way to force the AfterUpdate and other events that are bypassed when a hyperlink is clicked?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Did you notice that there are very few Events in a Label. Like maybe none. That probably means it cannot take the focus away from another Control. Not a particularly good choice for your alternative. Keep looking. You're getting warm.

  3. #3
    Old Goat is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    5
    Quote Originally Posted by RuralGuy View Post
    Did you notice that there are very few Events in a Label. Like maybe none. That probably means it cannot take the focus away from another Control. Not a particularly good choice for your alternative. Keep looking. You're getting warm.
    Thanks, RuralGuy. I've been programming Access for almost 20 years, and know the label control was not intended for this purpose. I would much rather be rewriting the application in C#, but that's another discussion entirely. Until then, I have to attempt to make a 15-year-old Access application look like a web page.

    There is an alternative...float a transparent command button over the label that calls the label's click event. That, however, eliminates the behavior of the the cursor turning into a hand when it is floated over the hyperlink. So, that is not a perfect solution, and I'm instead looking for maybe some command to put at the beginning of each hyperlink that would ensure all the normal events for the other controls fire just as if it was a command button.

    I tried stuff like DoCmd.RunCmd acCmdSaveXXXXXXXXXXX (tried a couple of different ones) and none of them worked.

    Oh, and in my original post, I misspoke. It is the LostFocus event of the text box control that fires when you click a command button, but not the hyperlink. As it turns out, I can get it to fire by adding a dummy text box, and setting focus to it when the hyperlink is clicked...so it looks like I've solved my problem. At least I hope so!

    Anyway, thanks for the help!

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Good luck with that project. Should be interesting, if nothing else.

  5. #5
    Old Goat is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    5
    Thanks, it has been. Another programmer and I have been working on it for about four months. and code freeze is next week. Other than a couple little issues like this one, it has turned out to my satisfaction. More importantly, my manger, the CEO, and our sales team are all very happy. Accounts Payable and General Ledger apps deployed in a Citrix environment. There's somewhere around 500 facilities around the nation that use it.

    Nothing against Access, but I look forward to the day when I get to program nothing but C#. :-)

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Understood.

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    How about replacing the old command buttons with unbound text boxes instead of using labels? You can control the unbound text boxes dynamically at the form level.

    I didn't read the entire thread but, you mentioned you were after a website look. So format the text box to look and behave like a hyperlink within a webpage. At the form level, use the exit event on the bound control to dynamically update your new unbound text box/hyperlink.

  8. #8
    Old Goat is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    5
    Quote Originally Posted by ItsMe View Post
    How about replacing the old command buttons with unbound text boxes instead of using labels? You can control the unbound text boxes dynamically at the form level. I didn't read the entire thread but, you mentioned you were after a website look. So format the text box to look and behave like a hyperlink within a webpage. At the form level, use the exit event on the bound control to dynamically update your new unbound text box/hyperlink.
    Provided the user uses a TAB or ENTER, that works just fine. The problem occurs when the user types something, and instead of tabbing or hitting enter, they grab the mouse and click the hyperlink. In that case, it bypasses the Lost Focus event. Really, the answer is using the Lost Focus event of a text box to do critical processing is poor form to state it politely as possible. For now, we're just adding a hidden text box called txtTabStop to the affected forms, and in the hyperlink calling the .SetFocus method of it. That fires the LostFocus event of the last control, so though it is a manual fix, we've solved it. Thanks for the help, folks!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 04-14-2012, 07:22 PM
  2. On-Click Event Procedure
    By tbassngal in forum Forms
    Replies: 6
    Last Post: 07-20-2011, 07:06 AM
  3. Allow right-click on Hyperlink to edit?
    By ThomasH in forum Access
    Replies: 3
    Last Post: 05-26-2011, 06:38 AM
  4. On Click Event Procedure
    By MrDean in forum Forms
    Replies: 3
    Last Post: 10-07-2009, 07:16 AM
  5. On-Click event transfer
    By nkenney in forum Forms
    Replies: 16
    Last Post: 03-26-2009, 09:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums