+ Reply to Thread
Results 1 to 5 of 5

Disable Form Events From Being Triggered

  1. #1
    JGeniti
    Guest

    Disable Form Events From Being Triggered

    Hello Group,

    I have read many of the postings regarding the fact that you can't
    disable form events. I have even created a Boolean called DisableEvent
    that I use to escape from the offending event code. My issue that I'm
    having is that I have 2 comboboxes and when I change the value of Box 1
    (From A to B) it needs to clear the value of Box 2. When the Box 2
    change event gets triggered the value of the box goes back to the
    original value (from B back to A) regardless of the fact that I am
    exiting the procedure before the code is executed.
    Any ideas?

    Here's the psuedocode of what's happening.

    Box1 value is changed from A to B

    Box1_OnChange
    DisableEvent = True
    Change Box 2 value to "" <This will trigger the Box2 Change Event>
    DisableEvent = False
    ....
    ....

    Box2_OnChange <This is when the value goes back to A>
    If DisableEvent = True then Exit Sub
    .....
    .....


  2. #2
    Tom Ogilvy
    Guest

    Re: Disable Form Events From Being Triggered

    Instead of using the change event, try using the click event.

    --
    Regards,
    Tom Ogilvy


    "JGeniti" <[email protected]> wrote in message
    news:[email protected]...
    > Hello Group,
    >
    > I have read many of the postings regarding the fact that you can't
    > disable form events. I have even created a Boolean called DisableEvent
    > that I use to escape from the offending event code. My issue that I'm
    > having is that I have 2 comboboxes and when I change the value of Box 1
    > (From A to B) it needs to clear the value of Box 2. When the Box 2
    > change event gets triggered the value of the box goes back to the
    > original value (from B back to A) regardless of the fact that I am
    > exiting the procedure before the code is executed.
    > Any ideas?
    >
    > Here's the psuedocode of what's happening.
    >
    > Box1 value is changed from A to B
    >
    > Box1_OnChange
    > DisableEvent = True
    > Change Box 2 value to "" <This will trigger the Box2 Change Event>
    > DisableEvent = False
    > ....
    > ....
    >
    > Box2_OnChange <This is when the value goes back to A>
    > If DisableEvent = True then Exit Sub
    > .....
    > .....
    >




  3. #3
    Bob Phillips
    Guest

    Re: Disable Form Events From Being Triggered

    Show us the real code.

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "JGeniti" <[email protected]> wrote in message
    news:[email protected]...
    > Hello Group,
    >
    > I have read many of the postings regarding the fact that you can't
    > disable form events. I have even created a Boolean called DisableEvent
    > that I use to escape from the offending event code. My issue that I'm
    > having is that I have 2 comboboxes and when I change the value of Box 1
    > (From A to B) it needs to clear the value of Box 2. When the Box 2
    > change event gets triggered the value of the box goes back to the
    > original value (from B back to A) regardless of the fact that I am
    > exiting the procedure before the code is executed.
    > Any ideas?
    >
    > Here's the psuedocode of what's happening.
    >
    > Box1 value is changed from A to B
    >
    > Box1_OnChange
    > DisableEvent = True
    > Change Box 2 value to "" <This will trigger the Box2 Change Event>
    > DisableEvent = False
    > ....
    > ....
    >
    > Box2_OnChange <This is when the value goes back to A>
    > If DisableEvent = True then Exit Sub
    > .....
    > .....
    >




  4. #4
    JGeniti
    Guest

    Re: Disable Form Events From Being Triggered

    -Tom
    I only want to trigger the code if the user changes the value. Won't
    the OnClick event cause the code to be triggered anytime someone clicks
    into the combobox?

    -Bob
    Here is the code. The PackageType combobox is Box1 from my above
    example. I still left out most of the code for the PackageComponent
    combobox because there is almost 200 lines of code and the value of
    PackageType gets changed back to the original value the instant that
    OnChange event gets called for the PackageComponent.

    Hopefully this will help. I just can't figure out why calling an
    OnChange event from within another Onchange would cause the original
    value to repopulate.

    Thanks.
    James

    Private Sub PackageType_Change()

    DisableEvent = True
    PackageComponent.Value = ""
    DisableEvent = False
    PackageComponent.RowSource = ""
    PackageComponent.Visible = False
    PackageComponentLabel.Visible = False

    End Sub


    Private Sub PackageComponent_Change()

    If DisableEvent = True Then Exit Sub
    DeletePackageFormControls

    .....
    .....
    ....


  5. #5
    Tom Ogilvy
    Guest

    Re: Disable Form Events From Being Triggered

    Click fires when an item is selected or if the user types in an item in the
    list or if you did the equivalent with code. Clearing the combobox did not
    fire the click event for me.

    Private Sub CommandButton1_Click()
    ComboBox1.ListIndex = -1
    End Sub

    Private Sub CommandButton2_Click()
    ComboBox1.Value = ""
    End Sub

    these did not fire the click event for me.

    --
    Regards,
    Tom Ogilvy


    "JGeniti" <[email protected]> wrote in message
    news:[email protected]...
    > -Tom
    > I only want to trigger the code if the user changes the value. Won't
    > the OnClick event cause the code to be triggered anytime someone clicks
    > into the combobox?
    >
    > -Bob
    > Here is the code. The PackageType combobox is Box1 from my above
    > example. I still left out most of the code for the PackageComponent
    > combobox because there is almost 200 lines of code and the value of
    > PackageType gets changed back to the original value the instant that
    > OnChange event gets called for the PackageComponent.
    >
    > Hopefully this will help. I just can't figure out why calling an
    > OnChange event from within another Onchange would cause the original
    > value to repopulate.
    >
    > Thanks.
    > James
    >
    > Private Sub PackageType_Change()
    >
    > DisableEvent = True
    > PackageComponent.Value = ""
    > DisableEvent = False
    > PackageComponent.RowSource = ""
    > PackageComponent.Visible = False
    > PackageComponentLabel.Visible = False
    >
    > End Sub
    >
    >
    > Private Sub PackageComponent_Change()
    >
    > If DisableEvent = True Then Exit Sub
    > DeletePackageFormControls
    >
    > ....
    > ....
    > ...
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1