kbay808
asked on
How to use VBA to build a string consisting of multiple strings, but only adding the strings based on whether or not the corresponding check box is checked in MS Access?
I have multiple check boxes in an access form that I need to combine all of the values for those that are check so that I can put it into a table. The problem is that the result has blank lines for the check boxes that are unchecked.
Example:
Check box 1: Missing contact name
Check box 2: Missing phone number
Check box 3: Missing email address
If I have the 1st and 3rd check boxes check the value looks like this:
Missing contact name
Missing email address
How can I remove the blank lines, but still keep each string on a different line?
Example:
Check box 1: Missing contact name
Check box 2: Missing phone number
Check box 3: Missing email address
Private Sub Test_Click()
If Me.Check292 = -1 Then result1 = "Missing contact name"
If Me.Check294 = -1 Then result2 = "Missing phone number"
If Me.Check309 = -1 Then result3 = "Missing email address"
result = result1 & vbCrLf & result2 & vbCrLf & result3
MsgBox result
End Sub
If I have the 1st and 3rd check boxes check the value looks like this:
Missing contact name
Missing email address
How can I remove the blank lines, but still keep each string on a different line?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That worked great... Thanks
Open in new window