Hal Levy said:
- A button is clicked to cancel changes on a form. That button calls a
form
cleanup routine. The cleanup does a cmbControl.text = "". I need to give
the control focus before doing that. So, I do a cmbControl.SetFocus. As
soon as the cmbControl.SetFocus is called it calls the On Click event for
the cmbControl. There is no mouse click or tabbing around. The focus is
called programatically- so I don't think it should be setting off the On
Click event.
Are you sure that it isn't your assignment to the cobo box's Text property
that is triggering the Click event? Normally, assignments to a control's
Value property do not trigger events, but assignments to the Text property
do. I can verify that assigning to the combo box's Text property *will*
fire the Click event. This is because it's treated like a manual update of
the combo box (by typing into it), and all manual updated of a combo box
fire the Click event.
HOWEVER, you do not need to assign to the Text property to clear the combo
box. If you assign to the combo box's Value property instead (its default
property), you don't need to set the focus to it at all. This is one way in
which Access controls differ from VB controls. The Text property has very
limited use and is only available when the control has the focus, but the
Value property has general use and is available anytime.
So, instead of this:
Me.cmbControl.SetFocus
Me.cmbControl.Text = ""
.... do this:
Me.cmbControl = Null
.... or possibly, if you really need to set the value to a zero-length string
(which I think unlikely), this:
Me.cmbControl = ""