ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   call a combobox KeyDown event from another procedure (https://www.excelbanter.com/excel-programming/432879-call-combobox-keydown-event-another-procedure.html)

Aleksander Śliwiński

call a combobox KeyDown event from another procedure
 
I have defined a combobox keydown (cbx_KeyDown) event in my UserForm module
that works when the user presses the Enter Key.
Now, I would like to call that procedure/event (with the Enter key passed)
from within a command button click event (cmd_Click).

The problem is that the code like the following:
call cbx_KeyDown(KeyCode: = 13, Shift: = 0)

reports a syntax error.

Alternatively when I write:
Call UserForm_KeyDown(13, 0)
I receive compile error Type Mismatch.

Is there a way of making it work?

Greetings,
Alexander Śliwiński




Rick Rothstein

call a combobox KeyDown event from another procedure
 
Event code is not really meant for you to call directly. The normal way of
handling what I think you are trying to do is to put the common code in a
subroutine (with arguments) and call it from your ComboBox KeyDown event and
from your CommandButton click event passing in the necessary arguments to
make it work the way you want.

--
Rick (MVP - Excel)


"Aleksander Śliwiński" wrote in message
...
I have defined a combobox keydown (cbx_KeyDown) event in my UserForm module
that works when the user presses the Enter Key.
Now, I would like to call that procedure/event (with the Enter key passed)
from within a command button click event (cmd_Click).

The problem is that the code like the following:
call cbx_KeyDown(KeyCode: = 13, Shift: = 0)

reports a syntax error.

Alternatively when I write:
Call UserForm_KeyDown(13, 0)
I receive compile error Type Mismatch.

Is there a way of making it work?

Greetings,
Alexander Śliwiński





Aleksander Sliwinski

call a combobox KeyDown event from another procedure
 
Thank you Rick,

I have used your suggestion and the job is done.

Greetings,
Alexander Sliwiński


Uzytkownik "Rick Rothstein" napisal w
wiadomosci ...
Event code is not really meant for you to call directly. The normal way of
handling what I think you are trying to do is to put the common code in a
subroutine (with arguments) and call it from your ComboBox KeyDown event
and from your CommandButton click event passing in the necessary arguments
to make it work the way you want.

--
Rick (MVP - Excel)


"Aleksander Śliwiński" wrote in message
...
I have defined a combobox keydown (cbx_KeyDown) event in my UserForm
module that works when the user presses the Enter Key.
Now, I would like to call that procedure/event (with the Enter key
passed) from within a command button click event (cmd_Click).

The problem is that the code like the following:
call cbx_KeyDown(KeyCode: = 13, Shift: = 0)

reports a syntax error.

Alternatively when I write:
Call UserForm_KeyDown(13, 0)
I receive compile error Type Mismatch.

Is there a way of making it work?

Greetings,
Alexander Śliwiński








All times are GMT +1. The time now is 12:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com