Re: Me. vs Me!
From: Dirk Goldgar (dg_at_NOdataSPAMgnostics.com)
Date: 06/04/04
- Next message: Marshall Barton: "Re: What Data Type: String of infinite len"
- Previous message: Ted Allen: "RE: Me. vs Me!"
- In reply to: Derek Wittman: "Me. vs Me!"
- Next in thread: Alex Ivanov: "Re: Me. vs Me!"
- Reply: Alex Ivanov: "Re: Me. vs Me!"
- Reply: Derek Wittman: "Re: Me. vs Me!"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 4 Jun 2004 17:06:50 -0400
"Derek Wittman" <anonymous@discussions.microsoft.com> wrote in message
news:AF58A59E-34D7-4FA2-A8F3-F639055A0BBA@microsoft.com
> Good morning,
> I know I saw something in the last few days on this topic, but I lost
> it. I continue to have to reference form controls like
> Forms!frmFORMNAME.controlname rather than (from form code)
> Me!controlname or Me.controlname.
>
> I did some hunting in the help files and they suggest that the Me! or
> Me. syntax may only be used in a class module (which I don't believe
> this qualifies as).
>
> Can someone please help me out?
> Thank you!
> Derek
Derek -
I looked through the earlier posts in this thread, and I'm not sure that
they made it clear that you can only use the "Me" keyword from VBA code
that is part of the form's (or report's) code module. That is, in code
"behind the form", you can use Me.controlname or Me!controlname to refer
to a control on that form, or Me.propertyname to refer to a property of
that form, but ...
(a) you can't use "Me" to refer to a form other than the one the
code is running on, and
(b) you can't use "Me" in a standard module; only in a class module
(a form or report's code module, or a user-defined class module), and
(c) you can't use "Me" in a controlsource expression or in a query.
If you are concerned with two forms, "FormA" and "FormB", then in code
running behind FormA you can refer to control txtFieldOnA on FormA using
any of these:
Me.txtFieldOnA
Me!txtFieldOnA
Forms!FormA!txtFieldOnA
(That last isn't as efficient as the others, though.) If there's a
control on *FormB* named txtFieldOnB, though, the only way you can refer
to it from code on FormA is
Forms!FormB!txtFieldOnB
or one of several equivalent versions of that reference syntax. You
can't use "Me", though, because txtFieldOnB isn't on "me" (FormA); it's
on FormB.
Does that explanation help at all?
-- Dirk Goldgar, MS Access MVP www.datagnostics.com (please reply to the newsgroup)
- Next message: Marshall Barton: "Re: What Data Type: String of infinite len"
- Previous message: Ted Allen: "RE: Me. vs Me!"
- In reply to: Derek Wittman: "Me. vs Me!"
- Next in thread: Alex Ivanov: "Re: Me. vs Me!"
- Reply: Alex Ivanov: "Re: Me. vs Me!"
- Reply: Derek Wittman: "Re: Me. vs Me!"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|