Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 355
Default Controls Question

I have the name of a control ("FormName.XControl") stored in a memory
variable (YVariable) I want to set the row source of xControl by referring to
the variable YVariable.

Instead of FormName.xControl.RowSource = ListName I want
YVariable.rowsource = ListName

How do I accomplish this?

Thank you

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Controls Question

The first line worked ok?
FormName.xControl.RowSource = ListName

Then did you do something like:

Set yVariable = FormName.xControl
yvariable.rowsource = listname

If it didn't work, you may want to share more of your code.

Sandy wrote:

I have the name of a control ("FormName.XControl") stored in a memory
variable (YVariable) I want to set the row source of xControl by referring to
the variable YVariable.

Instead of FormName.xControl.RowSource = ListName I want
YVariable.rowsource = ListName

How do I accomplish this?

Thank you


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 355
Default Controls Question

Thank you.


Yes, the 1st line works ok.

The name of the control that I want to set the row source for is already
stored in the memory variable called YVariable ("FormName.XControl").

After that I don't know how to refer to the control via the contents of
Yvariable.

"Dave Peterson" wrote:

The first line worked ok?
FormName.xControl.RowSource = ListName

Then did you do something like:

Set yVariable = FormName.xControl
yvariable.rowsource = listname

If it didn't work, you may want to share more of your code.

Sandy wrote:

I have the name of a control ("FormName.XControl") stored in a memory
variable (YVariable) I want to set the row source of xControl by referring to
the variable YVariable.

Instead of FormName.xControl.RowSource = ListName I want
YVariable.rowsource = ListName

How do I accomplish this?

Thank you


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Controls Question

Ahhh. YVariable is the name of the control--not a variable that represents the
control itself.

dim yVariable as string
yVariable = "somestring"

formname.controls(yVariable).rowsource = listname

(maybe???????)

If this code is behind the userform itself, I'd use:
me.controls(yVariable).rowsource = listname

Me represents the object that owns the code--in this case, it would be that
userform.

Sandy wrote:

Thank you.

Yes, the 1st line works ok.

The name of the control that I want to set the row source for is already
stored in the memory variable called YVariable ("FormName.XControl").

After that I don't know how to refer to the control via the contents of
Yvariable.

"Dave Peterson" wrote:

The first line worked ok?
FormName.xControl.RowSource = ListName

Then did you do something like:

Set yVariable = FormName.xControl
yvariable.rowsource = listname

If it didn't work, you may want to share more of your code.

Sandy wrote:

I have the name of a control ("FormName.XControl") stored in a memory
variable (YVariable) I want to set the row source of xControl by referring to
the variable YVariable.

Instead of FormName.xControl.RowSource = ListName I want
YVariable.rowsource = ListName

How do I accomplish this?

Thank you


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 355
Default Controls Question

I am sorry this is so confusing -- but it does show that I don't know how to
do this -- I appreciate your help.

The name of the control is FormName.XControl it is stored in a variable
called YVariable

YVariable = "FormName.XControl"

I want to be able to say the rowsource for the control whose name is stored
in YVariable is = "ListName"

"Dave Peterson" wrote:

Ahhh. YVariable is the name of the control--not a variable that represents the
control itself.

dim yVariable as string
yVariable = "somestring"

formname.controls(yVariable).rowsource = listname

(maybe???????)

If this code is behind the userform itself, I'd use:
me.controls(yVariable).rowsource = listname

Me represents the object that owns the code--in this case, it would be that
userform.

Sandy wrote:

Thank you.

Yes, the 1st line works ok.

The name of the control that I want to set the row source for is already
stored in the memory variable called YVariable ("FormName.XControl").

After that I don't know how to refer to the control via the contents of
Yvariable.

"Dave Peterson" wrote:

The first line worked ok?
FormName.xControl.RowSource = ListName

Then did you do something like:

Set yVariable = FormName.xControl
yvariable.rowsource = listname

If it didn't work, you may want to share more of your code.

Sandy wrote:

I have the name of a control ("FormName.XControl") stored in a memory
variable (YVariable) I want to set the row source of xControl by referring to
the variable YVariable.

Instead of FormName.xControl.RowSource = ListName I want
YVariable.rowsource = ListName

How do I accomplish this?

Thank you

--

Dave Peterson


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Controls Question

I would remove the characters "formname" from yVariable:

yVariable = "XControl"

Then use:
formname.controls(yVariable).rowsource = listname

But now I'm worried about what listname is.

Does listname look like an address?

dim ListName as string
listname = worksheets("Somesheet").range("a1:a10").address(ex ternal:=true)

or what???????


Sandy wrote:

I am sorry this is so confusing -- but it does show that I don't know how to
do this -- I appreciate your help.

The name of the control is FormName.XControl it is stored in a variable
called YVariable

YVariable = "FormName.XControl"

I want to be able to say the rowsource for the control whose name is stored
in YVariable is = "ListName"

"Dave Peterson" wrote:

Ahhh. YVariable is the name of the control--not a variable that represents the
control itself.

dim yVariable as string
yVariable = "somestring"

formname.controls(yVariable).rowsource = listname

(maybe???????)

If this code is behind the userform itself, I'd use:
me.controls(yVariable).rowsource = listname

Me represents the object that owns the code--in this case, it would be that
userform.

Sandy wrote:

Thank you.

Yes, the 1st line works ok.

The name of the control that I want to set the row source for is already
stored in the memory variable called YVariable ("FormName.XControl").

After that I don't know how to refer to the control via the contents of
Yvariable.

"Dave Peterson" wrote:

The first line worked ok?
FormName.xControl.RowSource = ListName

Then did you do something like:

Set yVariable = FormName.xControl
yvariable.rowsource = listname

If it didn't work, you may want to share more of your code.

Sandy wrote:

I have the name of a control ("FormName.XControl") stored in a memory
variable (YVariable) I want to set the row source of xControl by referring to
the variable YVariable.

Instead of FormName.xControl.RowSource = ListName I want
YVariable.rowsource = ListName

How do I accomplish this?

Thank you

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 355
Default Controls Question

again, thank you for your help -- I did as you last suggested and all is
well. ny list name is actually a named range within the excel file and it is
referred to as "ListName". This part works fine.


"Dave Peterson" wrote:

I would remove the characters "formname" from yVariable:

yVariable = "XControl"

Then use:
formname.controls(yVariable).rowsource = listname

But now I'm worried about what listname is.

Does listname look like an address?

dim ListName as string
listname = worksheets("Somesheet").range("a1:a10").address(ex ternal:=true)

or what???????


Sandy wrote:

I am sorry this is so confusing -- but it does show that I don't know how to
do this -- I appreciate your help.

The name of the control is FormName.XControl it is stored in a variable
called YVariable

YVariable = "FormName.XControl"

I want to be able to say the rowsource for the control whose name is stored
in YVariable is = "ListName"

"Dave Peterson" wrote:

Ahhh. YVariable is the name of the control--not a variable that represents the
control itself.

dim yVariable as string
yVariable = "somestring"

formname.controls(yVariable).rowsource = listname

(maybe???????)

If this code is behind the userform itself, I'd use:
me.controls(yVariable).rowsource = listname

Me represents the object that owns the code--in this case, it would be that
userform.

Sandy wrote:

Thank you.

Yes, the 1st line works ok.

The name of the control that I want to set the row source for is already
stored in the memory variable called YVariable ("FormName.XControl").

After that I don't know how to refer to the control via the contents of
Yvariable.

"Dave Peterson" wrote:

The first line worked ok?
FormName.xControl.RowSource = ListName

Then did you do something like:

Set yVariable = FormName.xControl
yvariable.rowsource = listname

If it didn't work, you may want to share more of your code.

Sandy wrote:

I have the name of a control ("FormName.XControl") stored in a memory
variable (YVariable) I want to set the row source of xControl by referring to
the variable YVariable.

Instead of FormName.xControl.RowSource = ListName I want
YVariable.rowsource = ListName

How do I accomplish this?

Thank you

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question for Peter T - Copy Paste controls at runtime Geoff Excel Programming 6 November 12th 06 08:05 PM
User controls on sheet question. - How to toggle between design and execute mode? Hexman Excel Programming 1 December 22nd 05 01:06 AM
Event procedures for controls added with Controls.Add John Austin[_4_] Excel Programming 1 March 9th 05 03:31 PM
Learning Macros and ActiveX controls...have a simple question... bizechick Excel Programming 1 November 12th 04 06:45 PM
General question: how many controls allowed? Mekratrig[_3_] Excel Programming 2 July 18th 04 12:05 AM


All times are GMT +1. The time now is 09:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"