Run code in Parent?

B

Bill

In the case of an Afterupdate Event in a
subform, can the event procedure "call"
a sub in the parent's code sheet?

If so, what would be the syntax of such
a call?

Thanks,
Bill
 
B

Bill

I made the sub in the Parent Public and
called thus: Call Me.Parent.SubName

It seemed to work okay, though I haven't
tested exhaustively.

"That" the right way?

Bill
 
M

Marshall Barton

I always thought the syntax for Call needed parenthesis:
Call Me.Parent.SubName(arglist)
or the alternate without Call:
Me.Parent.SubName arglist

In my view of things, barring the need to disambiguate the
Parent property from a VBA variable named Parent, using Me
is redundant and can be omitted. But I think that's a
matter of style in how much one feels the need to be
rigorous.
 
B

Bill

Interesting. To us very old programmers, VB in
general presents what are considered substantial
departures from syntax and conventions found
in earlier languages. So what might seem a logical
presentation of syntax to some, are radical nuances
to us. C++ is a better example of this than VB.

I've always been somewhat amazed with the
necessary use of "Me" when the scope and declaration
of variables is clear. My feeble brain seems to have
become corrupted to the point where I use "Me"
by default, rather than omit and risk being chastised
by the compiler or with runtime errors.

I've updated my code omitting "Me" as a qualifier
to "Parent".

As always, thank Marsh.

Bill


Marshall Barton said:
I always thought the syntax for Call needed parenthesis:
Call Me.Parent.SubName(arglist)
or the alternate without Call:
Me.Parent.SubName arglist

In my view of things, barring the need to disambiguate the
Parent property from a VBA variable named Parent, using Me
is redundant and can be omitted. But I think that's a
matter of style in how much one feels the need to be
rigorous.
--
Marsh
MVP [MS Access]

I made the sub in the Parent Public and
called thus: Call Me.Parent.SubName

It seemed to work okay, though I haven't
tested exhaustively.

"That" the right way?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top