Solved

Error 40036 when passing subform as a variable to procedure

Posted on 2015-01-25
5
360 Views
Last Modified: 2015-02-03
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
0
Comment
Question by:kmila
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 57

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 250 total points
ID: 40569328
When you call your procedure, call it using

[form]

So procedure looks like this:

Public sub MySub( frm as form)

Now in the procedure.  Use the variable form just as you would with Me

Jim
0
 
LVL 57
ID: 40569887
That should be frm not form.   Darn phone made a correction

Jim
0
 
LVL 37

Accepted Solution

by:
PatHartman earned 250 total points
ID: 40571211
If you are calling the procedure from the subform, then use Me.

Call SaveUpdate_OrderNote(Me, OtherParm)
0
 

Author Comment

by:kmila
ID: 40572024
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.
0
 
LVL 57
ID: 40572562
<<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.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question