Re: Can't get "Me" to work
From: el zorro (anonymous_at_discussions.microsoft.com)
Date: 10/29/04
- Next message: Infected04: "RE: Error 3075: missing operator"
- Previous message: Brian: "RE: Command button with conditions"
- In reply to: Dirk Goldgar: "Re: Can't get "Me" to work"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 29 Oct 2004 15:01:04 -0700
Right-- DotorsF is the form being opened by the code.
THanks for pointing out why it won't work. (I was
thinking that once the form was opened, "Me" would refer
to that form, not the form with the code. Now I get it--
Me refers to the form with the code!)
>-----Original Message-----
>"el zorro" <anonymous@discussions.microsoft.com> wrote
in message
>news:050f01c4bde7$08fdead0$a501280a@phx.gbl
>> I'm trying to optimize my VBA by refering to a form
field
>> using "Me" and the field name instead of including the
>> path beginning with "Forms," but I can't seem to get it
>> to work. (The form is opened from another form, from
>> which the user has selected a doctor. The new form
opens
>> to the appropriate doctor) Here's part of the code I
have
>> in the click event that opens the new form:
>>
>> stLinkCriteria = "[nDoc]=" & Me![nDoctor]
>>
>> 'Open form to selected doctor
>> DoCmd.OpenForm stDocName, , , stLinkCriteria
>> 'Don't allow user to change name of facility
>> Forms!DoctorsF!DocFacility.Locked = True
>>
>> THis works fine. But when I try to change that last
line
>> to something like this:
>> Me!DocFacility.Locked = True, or Me.DocFacility.Locked
=
>> True, it doesn't work. ANy idea where I'm going wrong?
>> THanks!
>
>Is "DoctorsF" the name of the form containing the code,
or the name of
>the form the code just opened? "Me" refers to the
object containing the
>executing code, so
>
>> Me!DocFacility.Locked = True
>
>will only work if DocFacility is a control on the form
where this line
>of code is being executed. I can't say for sure, but it
looks to me as
>though DoctorsF is the name of the form you're opening,
not the name of
>the form where this code resides.
>
>--
>Dirk Goldgar, MS Access MVP
>www.datagnostics.com
>
>(please reply to the newsgroup)
>
>
>.
>
- Next message: Infected04: "RE: Error 3075: missing operator"
- Previous message: Brian: "RE: Command button with conditions"
- In reply to: Dirk Goldgar: "Re: Can't get "Me" to work"
- Messages sorted by: [ date ] [ thread ]