Solved

Error 40036 when passing subform as a variable to procedure

Posted on 2015-01-25
5
352 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
  • 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 35

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Ms Access VBA Variables 6 26
Delete Records on a Form in Microsoft Access 5 35
Access Update Query 1 19
Obtaining Access 2013 Runtime file for Sagekey 2013 Installer 3 17
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

815 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now