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 / General 1 / May 2008

Tip: Looking for answers? Try searching our database.

looping thru the buttons in an option group

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sparks - 01 May 2008 16:48 GMT
well I am trying to get around looking at all the buttons with a case
statement so I was trying this.

Public Sub looking(ctlname)
Dim ctl As OptionGroup
Dim btn As ToggleButton
ctl = Me.Controls(ctlname)
=============================
For Each btn In ctl.children <<<< I know that the children doesn't
make since .its just a note to myself..this is where I am stumped.
I thought maybe ctl.controls but now shure what or how to loop thru
these
= ============================
 If btn.OptionValue = ctl.Value Then
   btn.ForeColor = 255
 Else
   btn.ForeColor = 0
 End If
Next

I was hoping to go thru the buttons in the option group and if it was
the selected button change the foreground color.

but I can't get the grasp of exactly what a button is in an
optiongroup
Marshall Barton - 01 May 2008 20:39 GMT
>well I am trying to get around looking at all the buttons with a case
>statement so I was trying this.
[quoted text clipped - 15 lines]
>  End If
>Next

For Each btn In ctl.Controls

--
Marsh
sparks - 02 May 2008 13:42 GMT
>>well I am trying to get around looking at all the buttons with a case
>>statement so I was trying this.
[quoted text clipped - 17 lines]
>
>For Each btn In ctl.Controls

now I get this on
ctl = Me.Controls(ctlname)
object variable or with block variable not set.

I am calling this with looking ("Q23Pass1Position")
passing a string as the control name I assume either this is wrong or
I am missing a library.
Marshall Barton - 02 May 2008 23:28 GMT
>>>well I am trying to get around looking at all the buttons with a case
>>>statement so I was trying this.
[quoted text clipped - 25 lines]
>passing a string as the control name I assume either this is wrong or
>I am missing a library.

Neither.  The error is because  you have to use Set with
object valiables:
    Set ctl = Me.Controls(ctlname)

Another way (preferable IMO) is to use:

Public Sub looking(ctl As OptionGroup)
Dim btn As ToggleButton
    For Each btn In ctl.Controls

And call it:
    looking Me.Q23Pass1Position

When calling a Sub procedure with just the procedure name,
don't use ( )  The ( ) won't work with a list of argumnets
and in your case above, they will convert the control object
to its Value property.

You do need ( ) if you call it this way:
    Call looking(Me.Q23Pass1Position)

--
Marsh
sparks - 05 May 2008 14:12 GMT
Thank you very much for clearing that up for me.
Will give it a try right now.

again  thanks for taking the time to explain it all.

>>>>well I am trying to get around looking at all the buttons with a case
>>>>statement so I was trying this.
[quoted text clipped - 46 lines]
>You do need ( ) if you call it this way:
>    Call looking(Me.Q23Pass1Position)
 
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.