News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

Formatting text box from Combo Box drop down selection

Started by tbaron27, September 04, 2019, 06:59:11 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tbaron27

I currently have a list of questions that need to be answered by the user completing the drawing and so i have created drop downs for them to select from using the Visio Combo box. I then found a way to format the text box that the question is located in based off of their selection within the combo box. The problem is that i used "case" programming and therefore i have to write scenarios for each of the drop down options. I really only care if the combo box is filled out or not. So basically while the combo box is empty, i want the text box next to it to be filled yellow. Once they select something, anything, then the text box should be filled white or no fill. Here is a sample of the current programming i'm using. i recorded a macro to call the setboxfill that you see below. i searched and search to find a simpler way but to no avail.

Private Sub ComboBox9_Change()

Select Case ComboBox9.Value
    Case Is = "GE"
        Call SetBoxFill9(255, 255, 255)
       
    Case Is = "DSC"
        Call SetBoxFill9(255, 255, 255)
                 
    Case Is = "Qolsys"
        Call SetBoxFill9(255, 255, 255)
                 
    Case Is = "N/A"
        Call SetBoxFill9(255, 255, 255)
                 
    Case Else
        Call SetBoxFill9(255, 255, 0)
End Select

End Sub

wapperdude

You ought to be able to use IF...then...else and use ISEMPTY:

if IsEmpty(ComboBox9.Value) then
   set the Color1
else
    set the Color2
end if

If that doesn't work, perhaps upload simple Visio file.
Visio 2019 Pro

tbaron27

So I tried the If IsEmpty and it worked when selecting something from the drop down, it changed the text box to white. However when I cleared the data from the combobox, it did not change the text box fill back to yellow. Seems like maybe i would need to include a "blank" choice in my drop down for it to work although i did not try that. Here is the code i tried:

If IsEmpty(ComboBox2.Value) Then
    Call SetBoxFill2(255, 255, 0)
   
Else
    Call SetBoxFill2(255, 255, 255)
End If

wapperdude

Clearing the form probably doesn't reset to empty.  The default might be "0" or "0.0000".  If you haves window open, you can use f8 to step thru code 1 line at a time.  Position mouse cursor over a variable and you'll see its value.  You'll have to decide which is more efficient, testing for allowable conditions or not allowable.
Visio 2019 Pro

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 187 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1055KB.
Tokens: post-login.
Cache hits: 13: 0.00201s for 26,733 bytes (show)
Cache misses: 2: (show)
Queries used: 16.

[Show Queries]