PC Review


Reply
Thread Tools Rate Thread

Listening for events on subform nested in a tab control

 
 
JIm Shaw
Guest
Posts: n/a
 
      23rd Nov 2003
I wish to synchronize a "MyPopUpForm" with custom events
generated in "MyMainForm" and "MySubForm".

MySubForm is nested on a page in a tab control
on "MyMainForm".

"MyPopUpForm" is opened via a control button on
MyMainForm, so I'm sure both MyMainForm and MySubForm are
loaded when MyPopUpForm fires its OnLoad event.

MyMainForm raises event "NewEmp(EmpID)" that MySubForm and
MyPopUpForm successfully handle.

So far, so good with my code. Now for what's not working..

MySubForm raises event CurRec(EffectiveDate).
MyPopUpForm should catch and handle the event by updating
a text box control with the EffectiveDate.

Problem: I keep getting messages at runtime that
MySubForm cannot be found.

Here's my code:
-----------------------------------------------------
On "MySubForm", I have declared a custom event in the
global area:

Public Event CurRec(EffectiveDate)

also I have:

Private Sub Form_Current()
RaiseEvent CurRec(EffectiveDate)
End Sub
--------------------------------------------
In the global area of "myPopUp" form I have:

Dim WithEvents subComp As Form_MySubForm

Then I coded:

Private Sub Form_Load()
Set subComp = Forms![frmEmpMaint]!MySubForm
End Sub
-------------------------------------------------

My problem is coding the proper syntax for the "Set
subComp" statement above. Various coding attempts have
all lead to runtime messages that generally say the
subform can't be found.

Does anyone you know know how to code this?
 
Reply With Quote
 
 
 
 
Dan Artuso
Guest
Posts: n/a
 
      24th Nov 2003
Hi,
The way to refer to a subform (which, by the way, is not a member of the open
forms collection) is:
Forms![frmEmpMaint].Form!NameOfSubformControl


--
HTH
Dan Artuso, Access MVP


"JIm Shaw" <(E-Mail Removed)> wrote in message news:028601c3b20e$1aecaaf0$(E-Mail Removed)...
> I wish to synchronize a "MyPopUpForm" with custom events
> generated in "MyMainForm" and "MySubForm".
>
> MySubForm is nested on a page in a tab control
> on "MyMainForm".
>
> "MyPopUpForm" is opened via a control button on
> MyMainForm, so I'm sure both MyMainForm and MySubForm are
> loaded when MyPopUpForm fires its OnLoad event.
>
> MyMainForm raises event "NewEmp(EmpID)" that MySubForm and
> MyPopUpForm successfully handle.
>
> So far, so good with my code. Now for what's not working..
>
> MySubForm raises event CurRec(EffectiveDate).
> MyPopUpForm should catch and handle the event by updating
> a text box control with the EffectiveDate.
>
> Problem: I keep getting messages at runtime that
> MySubForm cannot be found.
>
> Here's my code:
> -----------------------------------------------------
> On "MySubForm", I have declared a custom event in the
> global area:
>
> Public Event CurRec(EffectiveDate)
>
> also I have:
>
> Private Sub Form_Current()
> RaiseEvent CurRec(EffectiveDate)
> End Sub
> --------------------------------------------
> In the global area of "myPopUp" form I have:
>
> Dim WithEvents subComp As Form_MySubForm
>
> Then I coded:
>
> Private Sub Form_Load()
> Set subComp = Forms![frmEmpMaint]!MySubForm
> End Sub
> -------------------------------------------------
>
> My problem is coding the proper syntax for the "Set
> subComp" statement above. Various coding attempts have
> all lead to runtime messages that generally say the
> subform can't be found.
>
> Does anyone you know know how to code this?



 
Reply With Quote
 
 
 
 
Jim Shaw
Guest
Posts: n/a
 
      24th Nov 2003
Thanks for your response Dan, but that does not solve my
problem.

I tried your suggestion and at run time I get error
message # 2465 Can't find the field on the subform.

I'm not trying to reference a control on MySubForm, I'm
trying to reference the form its self to initalize subComp
which is of type "Form_MySubForm".

-Jim

>-----Original Message-----
>Hi,
>The way to refer to a subform (which, by the way, is not

a member of the open
>forms collection) is:
>Forms![frmEmpMaint].Form!NameOfSubformControl
>
>
>--
>HTH
>Dan Artuso, Access MVP
>
>
>"JIm Shaw" <(E-Mail Removed)> wrote in

message news:028601c3b20e$1aecaaf0$(E-Mail Removed)...
>> I wish to synchronize a "MyPopUpForm" with custom events
>> generated in "MyMainForm" and "MySubForm".
>>
>> MySubForm is nested on a page in a tab control
>> on "MyMainForm".
>>
>> "MyPopUpForm" is opened via a control button on
>> MyMainForm, so I'm sure both MyMainForm and MySubForm

are
>> loaded when MyPopUpForm fires its OnLoad event.
>>
>> MyMainForm raises event "NewEmp(EmpID)" that MySubForm

and
>> MyPopUpForm successfully handle.
>>
>> So far, so good with my code. Now for what's not

working..
>>
>> MySubForm raises event CurRec(EffectiveDate).
>> MyPopUpForm should catch and handle the event by

updating
>> a text box control with the EffectiveDate.
>>
>> Problem: I keep getting messages at runtime that
>> MySubForm cannot be found.
>>
>> Here's my code:
>> -----------------------------------------------------
>> On "MySubForm", I have declared a custom event in the
>> global area:
>>
>> Public Event CurRec(EffectiveDate)
>>
>> also I have:
>>
>> Private Sub Form_Current()
>> RaiseEvent CurRec(EffectiveDate)
>> End Sub
>> --------------------------------------------
>> In the global area of "myPopUp" form I have:
>>
>> Dim WithEvents subComp As Form_MySubForm
>>
>> Then I coded:
>>
>> Private Sub Form_Load()
>> Set subComp = Forms![frmEmpMaint]!MySubForm
>> End Sub
>> -------------------------------------------------
>>
>> My problem is coding the proper syntax for the "Set
>> subComp" statement above. Various coding attempts have
>> all lead to runtime messages that generally say the
>> subform can't be found.
>>
>> Does anyone you know know how to code this?

>
>
>.
>

 
Reply With Quote
 
Dan Artuso
Guest
Posts: n/a
 
      25th Nov 2003
Hi Jim,
Sorry, I was a dyslexic in my previous response.
It should be:
Forms![frmEmpMaint]!NameOfSubformControl.Form

NameOfSubformControl is the name of the container object on
your main form that 'contains' the subform. The container control has a Form property
that lets you get at the subform itself.

This is sometimes the same name as your subform but it depends on how
you let Access name it, or if you explicitly named it.

Also not sure about your dim statement. You could also try
Dim WithEvents subComp As Form


--
HTH
Dan Artuso, Access MVP


"Jim Shaw" <(E-Mail Removed)> wrote in message news:03c701c3b24c$ee1e2f00$(E-Mail Removed)...
> Thanks for your response Dan, but that does not solve my
> problem.
>
> I tried your suggestion and at run time I get error
> message # 2465 Can't find the field on the subform.
>
> I'm not trying to reference a control on MySubForm, I'm
> trying to reference the form its self to initalize subComp
> which is of type "Form_MySubForm".
>
> -Jim
>
> >-----Original Message-----
> >Hi,
> >The way to refer to a subform (which, by the way, is not

> a member of the open
> >forms collection) is:
> >Forms![frmEmpMaint].Form!NameOfSubformControl
> >
> >
> >--
> >HTH
> >Dan Artuso, Access MVP
> >
> >
> >"JIm Shaw" <(E-Mail Removed)> wrote in

> message news:028601c3b20e$1aecaaf0$(E-Mail Removed)...
> >> I wish to synchronize a "MyPopUpForm" with custom events
> >> generated in "MyMainForm" and "MySubForm".
> >>
> >> MySubForm is nested on a page in a tab control
> >> on "MyMainForm".
> >>
> >> "MyPopUpForm" is opened via a control button on
> >> MyMainForm, so I'm sure both MyMainForm and MySubForm

> are
> >> loaded when MyPopUpForm fires its OnLoad event.
> >>
> >> MyMainForm raises event "NewEmp(EmpID)" that MySubForm

> and
> >> MyPopUpForm successfully handle.
> >>
> >> So far, so good with my code. Now for what's not

> working..
> >>
> >> MySubForm raises event CurRec(EffectiveDate).
> >> MyPopUpForm should catch and handle the event by

> updating
> >> a text box control with the EffectiveDate.
> >>
> >> Problem: I keep getting messages at runtime that
> >> MySubForm cannot be found.
> >>
> >> Here's my code:
> >> -----------------------------------------------------
> >> On "MySubForm", I have declared a custom event in the
> >> global area:
> >>
> >> Public Event CurRec(EffectiveDate)
> >>
> >> also I have:
> >>
> >> Private Sub Form_Current()
> >> RaiseEvent CurRec(EffectiveDate)
> >> End Sub
> >> --------------------------------------------
> >> In the global area of "myPopUp" form I have:
> >>
> >> Dim WithEvents subComp As Form_MySubForm
> >>
> >> Then I coded:
> >>
> >> Private Sub Form_Load()
> >> Set subComp = Forms![frmEmpMaint]!MySubForm
> >> End Sub
> >> -------------------------------------------------
> >>
> >> My problem is coding the proper syntax for the "Set
> >> subComp" statement above. Various coding attempts have
> >> all lead to runtime messages that generally say the
> >> subform can't be found.
> >>
> >> Does anyone you know know how to code this?

> >
> >
> >.
> >



 
Reply With Quote
 
JIm Shaw
Guest
Posts: n/a
 
      29th Nov 2003
Thanks Dan, you were right on the money this time.
The DIM statement was OK
"NameOfSubformControl" was the problem. I was reading it
as "NameOfSubform.ControlName", leading to much
frustration. My code did not agree with how the
SubformControl was named. I was thinking it was the name
of the subform, not the name of a control on the main form
that contained my subform. I knew the control was there,
I just did not think it relevent to what I was trying to
accompish.
Once I started nosing around in the Object Brouser and saw
that my form name was not listed under my main form I got
suspicious and looked at the control properties in the
main form and found a completely different name (Much to
my surprise!)! When I used that name, everything worked
the way it should.

I really hate these "User Friendly" manuals that hide the
full story from the reader. ;-)

Many thanks
JIM



>-----Original Message-----
>Hi Jim,
>Sorry, I was a dyslexic in my previous response.
>It should be:
>Forms![frmEmpMaint]!NameOfSubformControl.Form
>
>NameOfSubformControl is the name of the container object

on
>your main form that 'contains' the subform. The container

control has a Form property
>that lets you get at the subform itself.
>
>This is sometimes the same name as your subform but it

depends on how
>you let Access name it, or if you explicitly named it.
>
>Also not sure about your dim statement. You could also try
>Dim WithEvents subComp As Form
>
>
>--
>HTH
>Dan Artuso, Access MVP
>
>
>"Jim Shaw" <(E-Mail Removed)> wrote in

message news:03c701c3b24c$ee1e2f00$(E-Mail Removed)...
>> Thanks for your response Dan, but that does not solve my
>> problem.
>>
>> I tried your suggestion and at run time I get error
>> message # 2465 Can't find the field on the subform.
>>
>> I'm not trying to reference a control on MySubForm, I'm
>> trying to reference the form its self to initalize

subComp
>> which is of type "Form_MySubForm".
>>
>> -Jim
>>
>> >-----Original Message-----
>> >Hi,
>> >The way to refer to a subform (which, by the way, is

not
>> a member of the open
>> >forms collection) is:
>> >Forms![frmEmpMaint].Form!NameOfSubformControl
>> >
>> >
>> >--
>> >HTH
>> >Dan Artuso, Access MVP
>> >
>> >
>> >"JIm Shaw" <(E-Mail Removed)> wrote

in
>> message news:028601c3b20e$1aecaaf0$(E-Mail Removed)...
>> >> I wish to synchronize a "MyPopUpForm" with custom

events
>> >> generated in "MyMainForm" and "MySubForm".
>> >>
>> >> MySubForm is nested on a page in a tab control
>> >> on "MyMainForm".
>> >>
>> >> "MyPopUpForm" is opened via a control button on
>> >> MyMainForm, so I'm sure both MyMainForm and MySubForm

>> are
>> >> loaded when MyPopUpForm fires its OnLoad event.
>> >>
>> >> MyMainForm raises event "NewEmp(EmpID)" that

MySubForm
>> and
>> >> MyPopUpForm successfully handle.
>> >>
>> >> So far, so good with my code. Now for what's not

>> working..
>> >>
>> >> MySubForm raises event CurRec(EffectiveDate).
>> >> MyPopUpForm should catch and handle the event by

>> updating
>> >> a text box control with the EffectiveDate.
>> >>
>> >> Problem: I keep getting messages at runtime that
>> >> MySubForm cannot be found.
>> >>
>> >> Here's my code:
>> >> -----------------------------------------------------
>> >> On "MySubForm", I have declared a custom event in

the
>> >> global area:
>> >>
>> >> Public Event CurRec(EffectiveDate)
>> >>
>> >> also I have:
>> >>
>> >> Private Sub Form_Current()
>> >> RaiseEvent CurRec(EffectiveDate)
>> >> End Sub
>> >> --------------------------------------------
>> >> In the global area of "myPopUp" form I have:
>> >>
>> >> Dim WithEvents subComp As Form_MySubForm
>> >>
>> >> Then I coded:
>> >>
>> >> Private Sub Form_Load()
>> >> Set subComp = Forms![frmEmpMaint]!MySubForm
>> >> End Sub
>> >> -------------------------------------------------
>> >>
>> >> My problem is coding the proper syntax for the "Set
>> >> subComp" statement above. Various coding attempts

have
>> >> all lead to runtime messages that generally say the
>> >> subform can't be found.
>> >>
>> >> Does anyone you know know how to code this?
>> >
>> >
>> >.
>> >

>
>
>.
>

 
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
listening to events causes null reference Torbjorn Stavas Microsoft Dot NET Compact Framework 3 8th Sep 2004 03:07 PM
Listening for events on subform nested in a tab control Jim Shaw Microsoft Access Form Coding 1 12th Jan 2004 06:20 PM
Listening to events published by other apps? wobbles Microsoft C# .NET 8 12th Dec 2003 08:22 PM
Repost: Listening for events on subform nested in a tab control Jim Shaw Microsoft Access Forms 2 25th Nov 2003 12:31 PM
Listening for threading events Keith Patrick Microsoft Dot NET Framework 3 20th Sep 2003 01:50 AM


Features
 

Advertising
 

Newsgroups
 


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