Call Event as Sub

C

Clayman

I have a need to force a ComboBox_Click() event. But, I think I already know
the answer - I just don't like it.

The ComboBox_Click() event populates a form. The user has the option to edit
some of the controls in the form. Some of these edits will change values in
other controls. Therefore, I would like to re-populate the form as if the
ComboBox was clicked.

The ComboBox_Change() event wasn't working in my situation. When I cleared
the ComboBox, it was kicking off the Change() event and I didn't want that.
This is why I used Click().

The answer I'm trying to avoid is create a sub that does everything in the
ComboBox_Click() event and call it from everywhere I need.
 
V

Vergel Adriano

Clay,

You should be able to call the Combo box click event handler just like how
you would call any sub routine.

Private Sub ComboBox1_Click()
MsgBox "combo box 1 was clicked!"
End Sub

Sub test()
'Call ComboBox1_Click
ComboBox1_Click
End Sub
 
C

Clayman

Found the problem:
ComboBox_Click() was in another form than the one with which I had problems.
I made it Public rather than Private and it worked.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top