## Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

• Help others & share knowledge
• Earn cash & points
Solved

# 4 Checkboxes Selected Captions should be Displayed in Textbox

Posted on 2011-02-27
363 Views
I have 4 Check Boxes in my Form, when the user selects more than one Checkbox and click on Command Button, the concatenated result of all Checkbox captions should be displayed in Textbox with "Or" in between each

If he selects only One, than Selected Checkbox caption only should be displayed without any "Or" , as he has selected only one checkbox

Below is my Code, what changes should be made to solve the above purpose,

Dim strMsg As String
If Me.CheckBox1 Then strMsg = strMsg & CheckBox1.Caption
If Me.CheckBox2 Then strMsg = strMsg & " Or " & CheckBox2.Caption
If Me.CheckBox3 Then strMsg = strMsg & " Or " & CheckBox3.Caption
If Me.CheckBox4 Then strMsg = strMsg & " Or " & CheckBox4.Caption
If Len(strMsg) = 0 Then
MsgBox "You should select any one value!'"
Else
TextBox1.Value = strMsg
End If

Problem with the above code is, if the user selects only second Checkbox than the result displayed in the Textbox is- Or Checkbox2 Caption
0
Question by:srikanthv2322
1 Comment

LVL 22

Accepted Solution

Thomasian earned 500 total points
ID: 34991695
``````    Dim strMsg As String

If Me.CheckBox1 Then strMsg = strMsg & CheckBox1.Caption & " Or "
If Me.CheckBox2 Then strMsg = strMsg & CheckBox2.Caption & " Or "
If Me.CheckBox3 Then strMsg = strMsg & CheckBox3.Caption & " Or "
If Me.CheckBox4 Then strMsg = strMsg & CheckBox4.Caption & " Or "
If Len(strMsg) = 0 Then
MsgBox "You should select any one value!'"
Else
TextBox1.Text = Left(strMsg, Len(strMsg) - 4)
End If
``````
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.