View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JMMach, MCSC JMMach, MCSC is offline
external usenet poster
 
Posts: 3
Default "Reading" Excel VBA checkboxes and their captions

Why not define the ON CHANGE event for each check box to define the
variable, or write it to a textbox, or maybe write it to a cell in your
spreadsheet as well? Are the checkboxes on a form or in the spreadsheet?
Are the checkboxes Active-X controls, or are they from the Forms toolbar?
The type of control will determine what properties the control has.
TTFN
JMMach

"Eliezer" wrote in message
...
I have a loop that calls this once for each of 44 sales
reps names, passing the name of the rep to this function
as an argument. There are 44 corresponding checkboxes
("ctl") which I want to "read" (i.e. determine whether
they're checked or not) and output a "true" or "false"
depending on whether the user checked that particular
rep's checkbox.


I have the following code:


Function isDesiredRep(repName As String) As Boolean
'loop through all rep names and read their respective
checkbox;
' if the rep's checkbox is checked, return TRUE
Dim ctl As Control
For Each ctl In mainForm.repsNames_frame.Controls
If ctl.Value = True And ctl.Caption = repName Then
isDesiredRep = True
Else
isDesiredRep = False
End If
Next
End Function



On the line that begins with "If ctl.value", I am getting
the error "Object doesn't support this property or method."

What am I doing wrong, please?

Thanks,
Eliezer