Solved

Error 40036 when passing subform as a variable to procedure

Posted on 2015-01-25
5
349 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 34

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

759 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

22 Experts available now in Live!

Get 1:1 Help Now