Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / May 2007

Tip: Looking for answers? Try searching our database.

creating string reference to control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Basil - 31 May 2007 10:34 GMT
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
RoyVidar - 31 May 2007 10:50 GMT
"Basil" <Basil@discussions.microsoft.com> wrote in message
<F269FB10-412F-45C4-923C-E397675E0CDB@microsoft.com>:
> Hiya,
>
[quoted text clipped - 19 lines]
>
> Basil

I think you would need to refer through the tab

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

Signature

Roy-Vidar

Basil - 31 May 2007 11:16 GMT
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

> "Basil" <Basil@discussions.microsoft.com> wrote in message
> <F269FB10-412F-45C4-923C-E397675E0CDB@microsoft.com>:
[quoted text clipped - 26 lines]
>     pg = "Page" & frameUpdate.Value
>     Me!MyTab.Pages(pg).SetFocus
Baz - 31 May 2007 11:31 GMT
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

> Thanks Roy.
>
[quoted text clipped - 36 lines]
> >     pg = "Page" & frameUpdate.Value
> >     Me!MyTab.Pages(pg).SetFocus
RoyVidar - 31 May 2007 11:52 GMT
"Baz" <bazz@REMOVEbcap.THEeuro1net.CAPScom> wrote in message
<465ea351$0$19255$da0feed9@news.zen.co.uk>:
> The value of a tab control is the ordinal position of the current
> page, so this will display the page corresponding to your option
[quoted text clipped - 42 lines]
>>>     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?)

Signature

Roy-Vidar

Baz - 31 May 2007 12:40 GMT
Might be, can't remember.  Anyway, you've got the general idea.

> Isn't it zero based?
>
> Me!MyTab.Value = frameUpdate.Value - 1
>
> (or renumber the options starting with 0?)
Scott McDaniel - 31 May 2007 11:27 GMT
>"Basil" <Basil@discussions.microsoft.com> wrote in message
><F269FB10-412F-45C4-923C-E397675E0CDB@microsoft.com>:
[quoted text clipped - 26 lines]
>    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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.