PC Review


Reply
Thread Tools Rate Thread

call a combobox KeyDown event from another procedure

 
 
Aleksander Śliwiński
Guest
Posts: n/a
 
      26th Aug 2009
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



 
Reply With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      26th Aug 2009
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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
>
>
>


 
Reply With Quote
 
Aleksander Sliwinski
Guest
Posts: n/a
 
      26th Aug 2009
Thank you Rick,

I have used your suggestion and the job is done.

Greetings,
Alexander Sliwiński


Uzytkownik "Rick Rothstein" <(E-Mail Removed)> napisal w
wiadomosci news:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>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
>>
>>
>>

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Call subform event procedure from main form event procedure ? =?Utf-8?B?cGxj?= Microsoft Access Form Coding 2 26th Oct 2006 10:15 PM
How to call an event procedure =?Utf-8?B?QmVu?= Microsoft Excel Programming 2 6th Dec 2005 05:40 PM
Call Event Procedure =?Utf-8?B?UmFuZHkgQ2hyaXN0aWFuc2Vu?= Microsoft Access Form Coding 5 6th Dec 2005 01:49 PM
how to capture KeyDown event in a ComboBox? jerry way Microsoft Dot NET Compact Framework 3 22nd Sep 2003 07:37 AM
Re: call event from procedure Eliyahu Goldin Microsoft C# .NET 0 1st Sep 2003 09:23 AM


Features
 

Advertising
 

Newsgroups
 


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