PC Review


Reply
Thread Tools Rate Thread

Sub to handle the same event in different forms

 
 
J. Moreno
Guest
Posts: n/a
 
      18th Aug 2006
I have an event handler (for keypress) and I want to use it multiple forms.

What's the best way of doing this?

I tried using

Public Sub cmbHandleKeyPress _
(Byval Sender as Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) _ Handles cmbMyMenu.Keypress,
frmOther.cmbOtherMenu.KeyPress

End Sub

but I get a build error.

Either I'm the first to think of this, or it's a really dumb thing to do,
because I can't find anyone else asking about it...

--
J. Moreno
 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGVubmlz?=
Guest
Posts: n/a
 
      19th Aug 2006
You might try creating (if you don't already have one) a general module class
then put your event handling sub in this module which will make it available
globally. Then in each form's new sub, use addhandler to add the
eventhandling sub to the event you want. You would't need the "handles...."
at the end of the sub declaration.
--
Dennis in Houston


"J. Moreno" wrote:

> I have an event handler (for keypress) and I want to use it multiple forms.
>
> What's the best way of doing this?
>
> I tried using
>
> Public Sub cmbHandleKeyPress _
> (Byval Sender as Object, ByVal e As
> System.Windows.Forms.KeyPressEventArgs) _ Handles cmbMyMenu.Keypress,
> frmOther.cmbOtherMenu.KeyPress
>
> End Sub
>
> but I get a build error.
>
> Either I'm the first to think of this, or it's a really dumb thing to do,
> because I can't find anyone else asking about it...
>
> --
> J. Moreno
>

 
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
How do you call the same Sub in 2 different forms =?Utf-8?B?d29ya3NmaXJlMQ==?= Microsoft Access VBA Modules 1 24th Aug 2007 10:57 PM
Can you do a sub-Form in a sub-Form ?? (Nest sub-Forms) MyEmailList@gmail.com Microsoft Access 2 25th Apr 2007 03:34 PM
main form, sub form, sub sub form ...etc =?Utf-8?B?RGF3blRyZWFkZXI=?= Microsoft Access Form Coding 8 5th Nov 2006 05:26 AM
How to create a 'Directory' in Access... or Categories & Sub-Cagegories & Sub-Sub-Categories & etc Will Microsoft Access 3 6th Sep 2005 04:51 AM
Re: Access 2003 Parent_Child relationships in sub and sub sub forms Allen Browne Microsoft Access 0 30th Jul 2004 05:23 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:33 PM.