I have a document with a table that has Active X combobox dropdowns and text boxes. Everything works great – my problem is when I reset the combobox – the MsgBox window displays twice when I include the following
Cbo_harm1.Value = “”
The code does what I want it to changes the combobox to "", but I don’t want the message box to be displayed twice which makes the user to select ok twice. If I do not include the Cbo_harm1.Value then it only displays once but does not reset the combobox. Can someone tell me why it is populating the MsgBox twice.
This is how I have the fields set up:
Probability text box, Harm combobox, Severity text box and a Final Risk textbox.
First text box (Probability) the user inputs a number, the next field is a combobox
(Harm) user chooses from the dropdown list. (I have code for the Harm combobox that if the users chooses Harm One then the Severity field will populate the number 1; Harm Two then the Severity will be 2 on and on… )
Once they have chosen the harm dropdown the severity field will populate and then another text box titled Final Risk will calculate the data from the two text boxes (Probability and Severity) – see below.
Example: Final Risk = Probability X Severity
Everything works great, but I am wanting the user to input in the first textbox (Probability) and next the combobox Harm - and it they do not input in the Probability field first - I have added code that “cbo_harm_Change() to display a message window stating that they need to input data in the Probability field, and then the combobox will change to equal “”
I can’t use the clear because on “Document open” I populate the list and do not want to lose that list.
Change Event Code: (I shortened up the code it does not include all of the If statements)
Sub cbo_harm_Change()
If txt_probability1.Text = "" Then
Application.ScreenUpdating = False
MsgBox "You must input a total for Initial Probability of Occurrence before selecting a Harm.", , "ERROR - Message"
cbo_harm1.Value = ""
txt_severity1.Value = ""
txt_initial_risk1.Value = ""
Exit Sub
Else
If cbo_harm1.Value = "Corneal Edema" Then
txt_severity1.Value = "3"
End If
End If
End Sub
Looking forward to hearing back and thank you for your help.