Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Feb 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    AfterUpdate (XP)

    I have a form on which there is a textbox control called "Amount Tendered". A value is programatically put in the box, which can be overridden by typing in the box. As expected, the Afterupdate event is triggered only when a value is typed in the box, not when a value is entered programatically. I have been able to simulate the Afterupdate event by calling that subrouting from the Onexit event of the control. This works fine for when I want the Afterupdate event to run, but I do not always want it to run every time I exit the textbox, such as when I click the Cancel button or change the "Pay Method" list box; when changing to one of these other controls, the textbox Onexit subroutine runs, which calls the textbox Afterupdate subroutine, not something I want to run in these cases. I am currently using flags set at various places to control exectuion of the Afterupdate routine, but with limited success since the Onexit routine can't determine what caused it to execute, causing the Onexit routine to run.

    Are there other solutions I haven't mentioned? Thanks for you help.

    My question concerns several potential solutions:

    Is there some way to force the Amount Tendered textbox to update, which would trigger the afterupdate event to run when leaving the control? This would be the simplist, if such a solution exists.

    Alternatively, is there some way to determine which control is requesting focus that the Amount Tendered textbox Onexit subroutine could detect and, thus, supress running the Afterupdate code.

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

    Re: AfterUpdate (XP)

    You could call the AfterUpdate event procedure of the Amount Tendered text box in the same code that places a value in this text box programmatically. That way, the AfterUpdate event procedure will only be called when it is needed.

  3. #3
    New Lounger
    Join Date
    Feb 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AfterUpdate (XP)

    Thanks for your response. Unfortunately, that would not solve my problem. My problem was not when or how the value was entered in the Amount Tendered box or how the box received focus. My problem was how do I know what to do when focus was lost or when exiting the box. Since I only wanted the Amount Tendered Afterupdate code to run only if Tab or Enter were pressed, I thought of using the Onkeypress event and checking to see if the Enter or Tab keys were pressed. But unfortunately, the event was not raised when those keys were pressed. It did when other keys were pressed but not Tab or Enter. The same was true with the OnKeyUp and OnKeyDown events.

    I finally came up with a solution that is a little round-about but works well. I placed a psudo hidden control (background and border set to transparent so it is not visable but still enabled), called Amount Tendered Event Relay, on the form. I then set the control tab order of the form so this relay control is the next to recieve focus after the Amount Tendered control--when Tab or Enter are pressed. The OnEnter event of the relay control executes the desired code, at the end of which focus is set to the next control the user is to use. Because only the OnEnter event of the relay control is used and no data is ever put in the control, the control is never seen unless you happen to know where the control is and click on it. This method forced the code to be run only when "Tabbing" or "Entering" out of Amount Tendered, whether or not it's value was entered programatically or by typing it in.

    Again, thanks for your response. Hope this solution helps someone else with a similar problem.

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

    Re: AfterUpdate (XP)

    But what if the user enters something, then clicks in another control?

  5. #5
    New Lounger
    Join Date
    Feb 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AfterUpdate (XP)

    Because the tabbing order of the form is set so that the relay control is the next control to receive focus after the Amount Tendered and code that ordinarily would be in the Amount Tendered Afterupdate event is, instead, placed in the OnEnter event of the relay. No action happens when focus is changed, regardless of whether the user entered anything in Amount Tendered or not, except when Tab or Enter is pressed causing the next control in the tab order, the relay control, to receive focus, thus executing the code. Hope that clarifies.

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

    Re: AfterUpdate (XP)

    If it is OK with you that no code is executed if the user enters something in the Amount Tendered control, then uses the mouse to click in another control, fine with me. I was just worried that that might not be what you intended.

  7. #7
    New Lounger
    Join Date
    Feb 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AfterUpdate (XP)

    That is exactly what I wanted. I only want to complete the sale if Tab or Enter is pressed. If the user clicks on something else, it means they are modifying the sale. Thanks for your input.

Posting Permissions

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