Single not Multiple AfterUpdate Events.

Discussion in 'AutoCAD' started by solarcad, Aug 8, 2003.

  1. solarcad

    solarcad Guest

    I have two text boxes that might get changed in any
    combination: 1st not 2nd, 2nd not first, or both.
    I need to do an AfterUpdate event only once for any
    of these combinations.

    If it was just the first two it would be easy of course - just an event for each control.  But how do I do only one event for
    both situations?
     
    solarcad, Aug 8, 2003
    #1
  2. solarcad

    solarcad Guest

    Yeah, except I am cycling through a list of blocks and that is an
    extra step each time for the user. I am trying to make it more
    transparent.  It is an instrument bubble that has to have the circle changed depending on the text string.  The text is changing by the change event. If the use doesn't pick the suggested update control then the text in the drawing won't match the circle. I'm looking for a way to have an update event
    for a group of controls rather than just one.

    Ed Jobe wrote:  How about another control like a button that the user selects when he's done changing the text boxes? 
    --
    Ed
    -- "solarcad" <> wrote in message news:...I have two text boxes that might get changed in any
    combination: 1st not 2nd, 2nd not first, or both.
    I need to do an AfterUpdate event only once for any
    of these combinations.

    If it was just the first two it would be easy of course - just an event for each control.  But how do I do only one event for
    both situations?
     
    solarcad, Aug 11, 2003
    #2
  3. solarcad,
    Since the textboxes can only be changed one at a time, it seems like it
    would be difficult to decide when to fire this hypothetical event. For
    example, if the user changes the 1st and not the 2nd, how long should the
    computer wait before it knows that the 2nd isn't going to be changed?

    Do you have a situation where some of the combinations of the 2 textboxes
    are invalid, and you don't want the update to occur when the user "passes
    through" these combinations? If this is the case, I'd do something like
    this.

    Sub txtBox1_AfterUpdate
    if ValidCombination() then ...
    end sub

    Sub txtBox2_AfterUpdate
    if ValidCombination() then ...
    end sub

    function ValidCombination() as Boolean
    'do checks on 2 text box values,
    'return true if you want to update the screen,
    ' false if you don't
    end Fuction

    James


    solarcad asked:
    If it was just the first two it would be easy of course - just an event for
    each control. But how do I do only one event for
    both situations?
     
    James Belshan, Aug 11, 2003
    #3
  4. solarcad

    solarcad Guest

    It seems a simple task but the logic gets complicated.
    I am getting a block(Block1) with two attributes and displaying them as two text boxes - say A and B.

    The user may change A but not B, B but not A, or A and B.
    I want to run one set of code for any of these combinations.
    Then the program cycles to Block2 and displays its attributes,etc.

    Any code run at the individual text objects AfterUpdate events gets executed twice if both objects are changed.
     
     

    James Belshan wrote: solarcad,
    Since the textboxes can only be changed one at a time, it seems like it
    would be difficult to decide when to fire this hypothetical event.  For
    example, if the user changes the 1st and not the 2nd, how long should the
    computer wait before it knows that the 2nd isn't going to be changed?

    Do you have a situation where some of the combinations of the 2 textboxes
    are invalid, and you don't want the update to occur when the user "passes
    through" these combinations?  If this is the case, I'd do something like
    this.

    Sub txtBox1_AfterUpdate
        if ValidCombination() then ...
    end sub

    Sub txtBox2_AfterUpdate
        if ValidCombination() then ...
    end sub

    function ValidCombination() as Boolean
       'do checks on 2 text box values,
       'return true if you want to update the screen,
       '  false if you don't
    end Fuction

    James

    solarcad asked:
    If it was just the first two it would be easy of course - just an event for
    each control.  But how do I do only one event for
    both situations?
     
    solarcad, Aug 11, 2003
    #4
  5. solarcad,
    Thank you for the background... it helps to visualise what you are working
    with, and trying to achieve.

    My question still stands, though... Let's say the user changes A but not B.
    How do you want to decide that the user is done making changes, and is not
    about to change B also? This will affect how you program it...

    The best way to me seems to be something like Ed's idea of a 'Done' button.
    I can't really see any other for the program to know when to move on to the
    next block...

    Looking forward to your answer.

    James
     
    James Belshan, Aug 11, 2003
    #5
  6. solarcad

    Ed Jobe Guest

    The only other thing I can think of is to set a flag when A or B is done.
    But that depends on what processing you are doing, which you havn't shown
    yet.
     
    Ed Jobe, Aug 11, 2003
    #6
  7. solarcad

    solarcad Guest

    The user would click a command button to move to the next block or exit the program.  That is why I was looking for something like an AfterUdate event that would work on both text boxes as a group instead of the individual text boxes.  Also I cannot just put it in the command button to go to the next block because it updates the text boxes and would trigger the event code.

    It is starting to like I have no choice but to do an Update command button. Just was hoping to make it more transparent.
     

    James Belshan wrote: solarcad,
    Thank you for the background... it helps to visualise what you are working
    with, and trying to achieve.

    My question still stands, though... Let's say the user changes A but not B.
    How do you want to decide that the user is done making changes, and is not
    about to change B also?  This will affect how you program it...

    The best way to me seems to be something like Ed's idea of a 'Done' button.
    I can't really see any other for the program to know when to move on to the
    next block...

    Looking forward to your answer.

    James
     
    solarcad, Aug 11, 2003
    #7
  8. solar,
    I think you can make it transparent if you want to, but it will have to run
    after each textbox is updated. After you change A, VBA has no way to know
    if you intend to change B or not.

    Questions for you:
    1) Why is it a problem to have the AfterUpdate code run twice? Is the code
    for the AfterUpdate process slow?
    2) Or is it that you just don't want 2 separate subroutines. In that
    case, I would suggest having the two AfterUpdate sub's simply call another
    (same) sub.
    3) Is it possible for the user to put invalid values, or invalid
    combinations of A and B, into the textboxes as he's typing the values? If
    so, use the Validation code I sent earlier to decide whether to run the bulk
    of your Update code.

    Hope this helps,

    James
     
    James Belshan, Aug 11, 2003
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.