Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Error 40036 when passing subform as a variable to procedure

Posted on 2015-01-25
5
Medium Priority
?
365 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 58

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 1000 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 58
ID: 40569887
That should be frm not form.   Darn phone made a correction

Jim
0
 
LVL 39

Accepted Solution

by:
PatHartman earned 1000 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 58
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

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 …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

661 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