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?
>> >
>> >
>> >.
>> >
>
>
>.
>
|