[AccessD] Refering to a control with a variable

Darryl Collins Darryl.Collins at iag.com.au
Thu May 20 18:34:47 CDT 2010


_______________________________________________________________________________________

Note: This e-mail is subject to the disclaimer contained at the bottom of this message.
_______________________________________________________________________________________




Dale,

I usually build all my variable first and then pass them into the code.
Make things much easier to debug and read

Forms(gstrFormName)(gstrSubForm).Form!(gstrMyControl).visible = true

Anyway, hope that helps a bit.

-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dale_Anne Kalsow
Sent: Friday, 21 May 2010 2:40 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Refering to a control with a variable

I know that me is refering to the current form but I do not see a "me" in the statment I am using (Forms![frmDate]![frmsubMonth].Form!("subFrom" & intloop & "").visible = False).  Would you mind just give the the syntac that will work? :)
 
thanks!
 
Dale

--- On Thu, 5/20/10, Gustav Brock <Gustav at cactus.dk> wrote:


From: Gustav Brock <Gustav at cactus.dk>
Subject: Re: [AccessD] Refering to a control with a variable
To: accessd at databaseadvisors.com
Date: Thursday, May 20, 2010, 11:34 AM


Hi Date

Me is always the calling form.
The syntax that worked is how to call a (sub)subform.

/gustav


>>> dkalsow at yahoo.com 20-05-2010 18:12 >>>
Sorry,

I don't understand why it is looking in the current form?  How do I tell it the subform than?

--- On Thu, 5/20/10, Gustav Brock <Gustav at cactus.dk> wrote:


From: Gustav Brock <Gustav at cactus.dk>
Subject: Re: [AccessD] Refering to a control with a variable
To: accessd at databaseadvisors.com 
Date: Thursday, May 20, 2010, 10:45 AM


Hi Dale

The last one would (if brushed up) try to reference a control on the calling form (Me) which is not what you want.

/gustav


>>> dkalsow at yahoo.com 20-05-2010 17:34 >>>
That worked Great - thanks!

Now----- why does the 2nd line work but not the 3rd?

intloop=8
Forms![frmDate]![frmsubMonth].Form![subForm8].visible = False
Forms![frmDate]![frmsubMonth].Form!("subFrom" & intloop & "").visible = False

Thanks Again!

Dale

--- On Thu, 5/20/10, Gustav Brock <Gustav at cactus.dk> wrote:


From: Gustav Brock <Gustav at cactus.dk>
Subject: Re: [AccessD] Refering to a control with a variable
To: accessd at databaseadvisors.com 
Date: Thursday, May 20, 2010, 9:52 AM


Hi Dale

This should do:

    Forms![frmDate]![frmsubMonth].Form("subForm" & intLoop & "").Form![lblDate].Caption = "Access"

/gustav


>>> dkalsow at yahoo.com 20-05-2010 16:31 >>>
Good Morning,

This is what I am trying to do:

    Forms![frmDate]![frmsubMonth].Form![subForm8].Form![lblDate].Caption = "jj"
    Dim intLoop As Integer
    intLoop = 8
    Me.Controls.Item("Forms![frmDate]![frmsubMonth].Form![subForm" & intLoop & "].Form![lblDate]").Caption = "Access"

The first line works.  Can anyone tell me why the last one does not?

Thanks in advance.

Dale
--- On Wed, 5/19/10, Stuart McLachlan <stuart at lexacorp.com.pg> wrote:


From: Stuart McLachlan <stuart at lexacorp.com.pg>
Subject: Re: [AccessD] Refering to a control with a variable
To: "Access Developers discussion and problem solving" <accessd at databaseadvisors.com>
Date: Wednesday, May 19, 2010, 10:15 PM


Me.Controls.Item("txtbox" & Trim(Str(IntA)))

(the "Me." is optional)

-- 
Stuart


On 19 May 2010 at 19:17, Dale_Anne Kalsow wrote:

> Good Evening,   If I have a control named txtbox1 and a variable of intA
> with a value of 1, does anyone know how to refer to the control in VBA
> with with something simular to "txtbox" & intA?   Thanks!   Dale 


-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



      
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
_______________________________________________________________________________________

The information transmitted in this message and its attachments (if any) is intended 
only for the person or entity to which it is addressed.
The message may contain confidential and/or privileged material. Any review, 
retransmission, dissemination or other use of, or taking of any action in reliance 
upon this information, by persons or entities other than the intended recipient is 
prohibited.

If you have received this in error, please contact the sender and delete this e-mail 
and associated material from any computer.

The intended recipient of this e-mail may only use, reproduce, disclose or distribute 
the information contained in this e-mail and any attached files, with the permission 
of the sender.

This message has been scanned for viruses.
_______________________________________________________________________________________




More information about the AccessD mailing list