Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Serbia and Montenegro (Yugoslavia)
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Click event firing and shouldn't be (VB6)

    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?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Click event firing and shouldn't be (VB6)

    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.)

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Click event firing and shouldn't be (VB6)

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

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Serbia and Montenegro (Yugoslavia)
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Click event firing and shouldn't be (VB6)

    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

  5. #5
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Click event firing and shouldn't be (VB6)

    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

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Serbia and Montenegro (Yugoslavia)
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Click event firing and shouldn't be (VB6)

    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.

Posting Permissions

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