error 2455 calling public sub in main form from subform (1 Viewer)

ozinm

Human Coffee Siphon
Local time
Today, 00:55
Joined
Jul 10, 2003
Messages
121
Ok,
I've got a weird one here i can't work out.
I have a main form (MainForm) that contains 2 subforms (subform1 & subform2).

MainForm contains a public sub called FilterSubForm2

The subform1 onCurrent event needs to call FilterSubForm2

I've tried
Code:
call me.form.parent.FilterSubForm2
call me.form.MainForm.FilterSubForm2
and various other derivations but keep getting the following error:
Code:
runtime error 2455
you entered an expression that has an invalid reference to the property Form/Report
End | Debug

If I hit the End button the code actually does what it's supposed to do!

Any ideas what's going wrong?
 

wazz

Super Moderator
Local time
Today, 07:55
Joined
Jun 29, 2004
Messages
1,711
i don't think you need all the extra stuff. just type:
FilterSubForm2
hth
 

boblarson

Smeghead
Local time
Yesterday, 16:55
Joined
Jan 12, 2001
Messages
32,059
Plus you don't need FORM when referring to the parent, but you do if you are referring to the subform within a subform container control.

call me.parent.FilterSubForm2
 

MStef

Registered User.
Local time
Today, 00:55
Joined
Oct 28, 2004
Messages
2,251
If the error still appear, try next,
before your code put;

On Error Resume Next
 

mad-q

Registered User.
Local time
Today, 00:55
Joined
Feb 14, 2010
Messages
61
Hello

I have been searching for ages for a solution to my problem, I am trying to call a public sub within a subform.

The main form is call Document Details
The subform is called DocumentDetailsSubform
and the sub is called GoToFirstRecord

I use
call me.form.DocumentDetailsSubform.GoToFirstRecord

and it returns the error
Run time error 438, Object doesn't support this property or method

Any help would be most appreciated.

Iain
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 00:55
Joined
Sep 12, 2006
Messages
15,660
i struggle with anything where a subform is trying to manipulate its container.

it always strikes me as a design error.

what are you doing in the subform, that needs to invoke a function in its parent?

-----
Ok - having reread it, I can see why you might want to do this, so maybe the function in the parent is declared as private. it needs to be public, I think, and then you ought to able to just do something like this.

parent.mysub
 

mad-q

Registered User.
Local time
Today, 00:55
Joined
Feb 14, 2010
Messages
61
You are correct, it is a bit of a bodge. I have now changed the way I do it. (fix my code)

Thanks
 

Users who are viewing this thread

Top Bottom