Using a form control name as a variable

J

Jim Shortslef

The line of code below changes the control source of Loc01
to JVYJV3.

Forms!frm_ViewRankSum.Controls!Loc01.ControlSource
= "JVYJV3"

How can I change the control name (Loc1) to a variable?

Jim
 
S

Sandra Daigle

Using a variable -

dim strCtlName as string
strCtlName = "Loc1"
Forms!frm_ViewRankSum.Controls(strCtlName).ControlSource = "JVYJV3"
 
J

Jim Shortslef

Sandra,

Using your suggestion results in the following error:

Type-declaration character does not match declared data
type.

Any other ideas?
-----Original Message-----
Using a variable -

dim strCtlName as string
strCtlName = "Loc1"
Forms!frm_ViewRankSum.Controls(strCtlName).ControlSource = "JVYJV3"

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.


Jim said:
The line of code below changes the control source of Loc01
to JVYJV3.

Forms!frm_ViewRankSum.Controls!Loc01.ControlSource
= "JVYJV3"

How can I change the control name (Loc1) to a variable?

Jim
.
 
S

Sandra Daigle

Hmmmm . . . in a similar test it works for me - perhaps the problem is that
I inadvertantly changed the control name to Loc1? Should be:

dim strCtlName as string
strCtlName = "Loc01"
Forms!frm_ViewRankSum.Controls(strCtlName).ControlSource = "JVYJV3"

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Jim said:
Sandra,

Using your suggestion results in the following error:

Type-declaration character does not match declared data
type.

Any other ideas?
-----Original Message-----
Using a variable -

dim strCtlName as string
strCtlName = "Loc1"
Forms!frm_ViewRankSum.Controls(strCtlName).ControlSource = "JVYJV3"

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.


Jim said:
The line of code below changes the control source of Loc01
to JVYJV3.

Forms!frm_ViewRankSum.Controls!Loc01.ControlSource
= "JVYJV3"

How can I change the control name (Loc1) to a variable?

Jim
.
 
J

Jim Shortslef

You are correct.

Thanks for the help.

Jim
-----Original Message-----
Hmmmm . . . in a similar test it works for me - perhaps the problem is that
I inadvertantly changed the control name to Loc1? Should be:

dim strCtlName as string
strCtlName = "Loc01"
Forms!frm_ViewRankSum.Controls(strCtlName).ControlSource = "JVYJV3"

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Jim said:
Sandra,

Using your suggestion results in the following error:

Type-declaration character does not match declared data
type.

Any other ideas?
-----Original Message-----
Using a variable -

dim strCtlName as string
strCtlName = "Loc1"
Forms!frm_ViewRankSum.Controls (strCtlName).ControlSource = "JVYJV3"

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.


Jim Shortslef wrote:
The line of code below changes the control source of Loc01
to JVYJV3.

Forms!frm_ViewRankSum.Controls!Loc01.ControlSource
= "JVYJV3"

How can I change the control name (Loc1) to a variable?

Jim
.

.
 

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