• Click event firing and shouldn’t be (VB6)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Click event firing and shouldn’t be (VB6)

    Author
    Topic
    #408707

    I have a regular combo box that I’ve populated with fixed values from a collection object. One of the values is “OTHER”. I needed to test the value of the ComboBox for OTHER and them make visible another text field on the same form. I’m using the LostFocus event to do this test, which works great if they tab out of the field (Validate didn’t fire for all conditions I needed). So I also wanted to handle the condition where the user uses the mouse to select OTHER. I used the click event of the ComboBox to test this action, but whenever you type anything in, the click event fires. I thought it only was supposed to fire when using the mouse. So how do I handle surpressing or passing over the code in the click event unless the user, well, clicks on a value?

    Viewing 3 reply threads
    Author
    Replies
    • #865300

      Can you use the Change event, or does that also require tabbing out?

      (I have no idea about the Click problem, and I suspect testing the VBA controls in an Office application won’t tell me anything pertinent to the VB6 controls.)

    • #865301

      Can you use the Change event, or does that also require tabbing out?

      (I have no idea about the Click problem, and I suspect testing the VBA controls in an Office application won’t tell me anything pertinent to the VB6 controls.)

    • #865320

      Try the Validate event. It works like BeforeUpdate in VBA.

      • #866163

        Charlotte, should the click event even be firing at all when the user is typing on the keyboard? I thought that event captured mouse clicks only

        • #866377

          FWIW, according to an “official” source (MSDN):

          Click Event

          This event “occurs when the user presses and then releases a mouse button over an object. It can also occur when the value of a control is changed.” And: “Selects an item in a ComboBox or ListBox control, either by pressing the arrow keys or by clicking the mouse button.” Not much else specific to combobox control. According to unofficial (but reliable?) source (Visual Basic Controls In A Nutshell (O’Reilly Press)), the ComboBox Click event takes place any time the user scrolls thru the list and selects items, “whether by mouse, keyboard, or code.” Also, changing the ListIndex property in code will fire the Click event. The Change event indicates that the text in text portion of combobox has changed (simple and drop-down style comboboxes). The Scroll event is fired whenever list is scrolled, whether by mouse or keyboard. In any event it appears the Click event is not limited to mouse input when triggered.

          You will probably have to experiment to find the right sequence of events to accomplish task.

          HTH

          • #866558

            Mark,

            Thanks, that was helpful. If nothing else it makes me more comfortable with the hassle of 3rd party controls. I ended up writing code around it to make it do what I needed.

          • #866559

            Mark,

            Thanks, that was helpful. If nothing else it makes me more comfortable with the hassle of 3rd party controls. I ended up writing code around it to make it do what I needed.

        • #866378

          FWIW, according to an “official” source (MSDN):

          Click Event

          This event “occurs when the user presses and then releases a mouse button over an object. It can also occur when the value of a control is changed.” And: “Selects an item in a ComboBox or ListBox control, either by pressing the arrow keys or by clicking the mouse button.” Not much else specific to combobox control. According to unofficial (but reliable?) source (Visual Basic Controls In A Nutshell (O’Reilly Press)), the ComboBox Click event takes place any time the user scrolls thru the list and selects items, “whether by mouse, keyboard, or code.” Also, changing the ListIndex property in code will fire the Click event. The Change event indicates that the text in text portion of combobox has changed (simple and drop-down style comboboxes). The Scroll event is fired whenever list is scrolled, whether by mouse or keyboard. In any event it appears the Click event is not limited to mouse input when triggered.

          You will probably have to experiment to find the right sequence of events to accomplish task.

          HTH

      • #866164

        Charlotte, should the click event even be firing at all when the user is typing on the keyboard? I thought that event captured mouse clicks only

    • #865321

      Try the Validate event. It works like BeforeUpdate in VBA.

    Viewing 3 reply threads
    Reply To: Click event firing and shouldn’t be (VB6)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: