creating string reference to control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hiya,

I have a load of tabs page1, page2, page3, etc

I have an option group above. When the user clicks the option, it will
return a value (1,2,3,4,...). I want it to set focus to the corresponding
page but am having trouble making a dynamic reference to the page control.
Can you help please?

This is my code that is failing:

Private Sub frameUpdate_Click()

Dim pg As String 'also doesn't work when set to be a Control

pg = "Page" & frameUpdate.Value
Me.[pg].SetFocus

End Sub

Thanks loads,

Basil
 
Basil said:
Hiya,

I have a load of tabs page1, page2, page3, etc

I have an option group above. When the user clicks the option, it
will return a value (1,2,3,4,...). I want it to set focus to the
corresponding page but am having trouble making a dynamic reference
to the page control. Can you help please?

This is my code that is failing:

Private Sub frameUpdate_Click()

Dim pg As String 'also doesn't work when set to be a Control

pg = "Page" & frameUpdate.Value
Me.[pg].SetFocus

End Sub

Thanks loads,

Basil

I think you would need to refer through the tab

pg = "Page" & frameUpdate.Value
Me!MyTab.Pages(pg).SetFocus
 
Thanks Roy.

I'm pretty sure there's another way though that is more simple and widely
useable. I asked the question before but MSDN removed it. (the work is at a
previous company so can't reference).

Thanks though, I'll use this in the meantime.

B

RoyVidar said:
Basil said:
Hiya,

I have a load of tabs page1, page2, page3, etc

I have an option group above. When the user clicks the option, it
will return a value (1,2,3,4,...). I want it to set focus to the
corresponding page but am having trouble making a dynamic reference
to the page control. Can you help please?

This is my code that is failing:

Private Sub frameUpdate_Click()

Dim pg As String 'also doesn't work when set to be a Control

pg = "Page" & frameUpdate.Value
Me.[pg].SetFocus

End Sub

Thanks loads,

Basil

I think you would need to refer through the tab

pg = "Page" & frameUpdate.Value
Me!MyTab.Pages(pg).SetFocus
 
Basil said:
Hiya,

I have a load of tabs page1, page2, page3, etc

I have an option group above. When the user clicks the option, it
will return a value (1,2,3,4,...). I want it to set focus to the
corresponding page but am having trouble making a dynamic reference
to the page control. Can you help please?

This is my code that is failing:

Private Sub frameUpdate_Click()

Dim pg As String 'also doesn't work when set to be a Control

pg = "Page" & frameUpdate.Value
Me.[pg].SetFocus

End Sub

Thanks loads,

Basil

I think you would need to refer through the tab

pg = "Page" & frameUpdate.Value
Me!MyTab.Pages(pg).SetFocus

I've had some odd instances where the above didn't work correctly (for the most part, it works perfectly fine), however
I've always used the Cstr function to make sure:

pg = "Page" & Cstr(frameUpdate.Value)



Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 
The value of a tab control is the ordinal position of the current page, so
this will display the page corresponding to your option buttons:

tabOfMine.Value = frameUpdate.Value


Basil said:
Thanks Roy.

I'm pretty sure there's another way though that is more simple and widely
useable. I asked the question before but MSDN removed it. (the work is at a
previous company so can't reference).

Thanks though, I'll use this in the meantime.

B

RoyVidar said:
Basil said:
Hiya,

I have a load of tabs page1, page2, page3, etc

I have an option group above. When the user clicks the option, it
will return a value (1,2,3,4,...). I want it to set focus to the
corresponding page but am having trouble making a dynamic reference
to the page control. Can you help please?

This is my code that is failing:

Private Sub frameUpdate_Click()

Dim pg As String 'also doesn't work when set to be a Control

pg = "Page" & frameUpdate.Value
Me.[pg].SetFocus

End Sub

Thanks loads,

Basil

I think you would need to refer through the tab

pg = "Page" & frameUpdate.Value
Me!MyTab.Pages(pg).SetFocus
 
Baz said:
The value of a tab control is the ordinal position of the current
page, so this will display the page corresponding to your option
buttons:

tabOfMine.Value = frameUpdate.Value


Basil said:
Thanks Roy.

I'm pretty sure there's another way though that is more simple and
widely useable. I asked the question before but MSDN removed it.
(the work is at a previous company so can't reference).

Thanks though, I'll use this in the meantime.

B

RoyVidar said:
<[email protected]>:
Hiya,

I have a load of tabs page1, page2, page3, etc

I have an option group above. When the user clicks the option, it
will return a value (1,2,3,4,...). I want it to set focus to the
corresponding page but am having trouble making a dynamic
reference to the page control. Can you help please?

This is my code that is failing:

Private Sub frameUpdate_Click()

Dim pg As String 'also doesn't work when set to be a Control

pg = "Page" & frameUpdate.Value
Me.[pg].SetFocus

End Sub

Thanks loads,

Basil

I think you would need to refer through the tab

pg = "Page" & frameUpdate.Value
Me!MyTab.Pages(pg).SetFocus

Isn't it zero based?

Me!MyTab.Value = frameUpdate.Value - 1

(or renumber the options starting with 0?)
 
Back
Top