PC Review


Reply
Thread Tools Rate Thread

Catching a custom form event in another instance

 
 
=?Utf-8?B?RGlyaw==?=
Guest
Posts: n/a
 
      22nd Nov 2005
Hi,

I have this form I use to look for contacts and it uses the following event:

Public Event ContactSelected(nCNT_ID As Integer)

Whenever a contact is selected the following code is ran to raise the event
and pass the ID of the selected contact:

RaiseEvent ContactSelected(CNT_ID.Value)

On my calling form I declare a form like:

Public WithEvents frmSearch As Form

To try and catch the event this form raises I use something like:
DoCmd.OpenForm("Search")
Set frmSearch = Forms("Search")

I am also using a sub to try and catch the event but this doesn't seem to
ever get called even though I do raise the event.

Public Sub frmSearch_ContactSelected(nCNT_ID As Integer)
Me.nCNT_ID = nCNT_ID
MsgBox "Found: " & nCNT_ID
End Sub

Please does anyone know how to catch a form's custom event?

 
Reply With Quote
 
 
 
 
Alex Dybenko
Guest
Posts: n/a
 
      22nd Nov 2005
Hi,
i think you have instantiate a form using its class:

dim frmSearch as Form_Search

set frmSearch = new Form_Search
frmSearch.visible=true

Also you can try to use form's open event (but i am not sure)
Set frmSearch = Form_Search


--
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com



"Dirk" <(E-Mail Removed)> wrote in message
news:4305B5D8-711E-40E8-B3BD-(E-Mail Removed)...
> Hi,
>
> I have this form I use to look for contacts and it uses the following
> event:
>
> Public Event ContactSelected(nCNT_ID As Integer)
>
> Whenever a contact is selected the following code is ran to raise the
> event
> and pass the ID of the selected contact:
>
> RaiseEvent ContactSelected(CNT_ID.Value)
>
> On my calling form I declare a form like:
>
> Public WithEvents frmSearch As Form
>
> To try and catch the event this form raises I use something like:
> DoCmd.OpenForm("Search")
> Set frmSearch = Forms("Search")
>
> I am also using a sub to try and catch the event but this doesn't seem to
> ever get called even though I do raise the event.
>
> Public Sub frmSearch_ContactSelected(nCNT_ID As Integer)
> Me.nCNT_ID = nCNT_ID
> MsgBox "Found: " & nCNT_ID
> End Sub
>
> Please does anyone know how to catch a form's custom event?
>


 
Reply With Quote
 
=?Utf-8?B?RGlyaw==?=
Guest
Posts: n/a
 
      23rd Nov 2005
Thank you very much, you are right

After trying a few things out yesterday I noticed that I could get a typed
reference to my forms too which did indeed expose the custom event handler.

So to recap:

Declaration:
Private WithEvents frmZoeken As Form_SearchContact

To get a reference:
DoCmd.OpenForm ("SearchContact")
Set frmSearch = Forms("SearchContact")

> Hi,
> i think you have instantiate a form using its class:
>
> dim frmSearch as Form_Search
>
> set frmSearch = new Form_Search
> frmSearch.visible=true
>
> Also you can try to use form's open event (but i am not sure)
> Set frmSearch = Form_Search
>
>
> --
> Alex Dybenko (MVP)
> http://alexdyb.blogspot.com
> http://www.PointLtd.com
>
>
>
> "Dirk" <(E-Mail Removed)> wrote in message
> news:4305B5D8-711E-40E8-B3BD-(E-Mail Removed)...
> > Hi,
> >
> > I have this form I use to look for contacts and it uses the following
> > event:
> >
> > Public Event ContactSelected(nCNT_ID As Integer)
> >
> > Whenever a contact is selected the following code is ran to raise the
> > event
> > and pass the ID of the selected contact:
> >
> > RaiseEvent ContactSelected(CNT_ID.Value)
> >
> > On my calling form I declare a form like:
> >
> > Public WithEvents frmSearch As Form
> >
> > To try and catch the event this form raises I use something like:
> > DoCmd.OpenForm("Search")
> > Set frmSearch = Forms("Search")
> >
> > I am also using a sub to try and catch the event but this doesn't seem to
> > ever get called even though I do raise the event.
> >
> > Public Sub frmSearch_ContactSelected(nCNT_ID As Integer)
> > Me.nCNT_ID = nCNT_ID
> > MsgBox "Found: " & nCNT_ID
> > End Sub
> >
> > Please does anyone know how to catch a form's custom event?
> >

>
>

 
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
Incorrect instance in .NET 2.0 Form Shown event Victory Microsoft C# .NET 1 22nd Apr 2007 08:54 PM
Custom Form-Catching item,inspector Save event =?Utf-8?B?YmFjazJncmlk?= Microsoft Outlook Form Programming 0 13th Jun 2005 08:57 PM
Catching a RequiredFiled Validator event in PageLoad or some other event? Lars Netzel Microsoft ASP .NET 3 22nd Jul 2004 11:48 PM
Load event firing twice for one form instance C M Shaw Microsoft Dot NET Framework Forms 8 15th Jan 2004 01:00 AM
Load event firing twice for one form instance C M Shaw Microsoft VB .NET 4 7th Jan 2004 08:46 AM


Features
 

Advertising
 

Newsgroups
 


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