Returning the caption more than one active control within a frame

trishgyrl

New Member
Joined
Jan 16, 2018
Messages
21
Hello...

Can someone please help. I have a frame within a user form that contains 6 checkboxes. The user may select more than one checkbox.

I am trying to send the caption of the selected checkbox(es) to the body of an email. I wrote the code below but it returned the same one twice (see the bolded portion).

Does anyone know I can achieve this? Thanks in advance.

Code:
"<br><br>" & _    "<b>" & Me.lblNewExist & ": " & "</b>" & Me.frameNewExist.ActiveControl.Caption & _
    "<br><br>" & _
[B]    "<b>" & Me.frameDealType.Caption & ": " & "</b>" & Me.frameDealType.ActiveControl.Caption & _[/B]
[B]    "<br><br>"[/B]
[B]    strBody = strBody & "<b>" & Me.frameDealType.Caption & ": " & "</b>" & Me.frameDealType.ActiveControl.Caption & _[/B]
[B]    "<br><br>" & _[/B]
    "<b>" & Me.frameDeal.Caption & ": " & "</b>" & Me.frameDeal.ActiveControl.Text & " - " & Me.frameRecDel.ActiveControl.Caption & _
    "<br><br>" & _
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hi,

try looping through all your checkboxes to build your string variable


untested but something like following may do what you want


Code:
    Dim Ctrl As Control
    For Each Ctrl In Me.frameNewExist.Controls
        With Ctrl
            If TypeName(Ctrl) = "CheckBox" Then
'box checked
                If .Value Then strBody = IIf(Len(strBody) = 0, .Caption, strBody & ": " & .Caption)
            End If
        End With
    Next Ctrl

adjust code as required.

Dave
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,148
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top