Link to home
Start Free TrialLog in
Avatar of kmila
kmila

asked on

Error 40036 when passing subform as a variable to procedure

Hi, I'm trying to pass a subform as a variable to a pocedure to be able to access this subform's properties (i.e refresh it later on)

If used the syntax described here but to no effect. I keep getting error 40036 "Method Item of object Forms failed" on the following line of code:

260   Set fForm = Forms!New_frmZamowienia_DaneRzeczywiste!subform_Notes.Form

Open in new window


My main form is named: New_frmZamowienia_DaneRzeczywiste
The sub form is named: subform_Notes

The sub form is on a page control tab
Sub and main form are linked through a field.

I'm attaching the whole procedure.
Sub.txt
SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That should be frm not form.   Darn phone made a correction

Jim
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kmila
kmila

ASKER

Hi, substituting
Set fForm = Forms!New_frmZamowienia_DaneRzeczywiste!subform_Notes.Form

with a form object I've passed the Me variable earlier on to worked.

Set fForm = fCallingForm

Thanks for that.

Is there some inherent problem with the way I was trying to assign the form variable. I mean I can still think of a situation where I would need to point directly to a subform from the forms collection.
<<Is there some inherent problem with the way I was trying to assign the form variable.>>

The only tricky part to this:

Set fForm = Forms!New_frmZamowienia_DaneRzeczywiste!subform_Notes.Form

 is that you need to refer to the sub form *control* name on the main form, not the sub forms actual name form name as it appears in the database container.  They may not be one in the same.

Jim.