A1VBCode Forums

Word - VBA script to display text on form


http://www.a1vbcode.com/vbforums/Topic27849.aspx

By Barry - 6/29/2009

I need to create a Word macro/vba script to display text to the right of a form field if a particular field value is select from the list of values. I currently have a script (Dropdown8 is a combo box, Text22 is a text box) that works (below), but only changes the text if, after changing the value in Dropdown8, you tab to another field and then reselect it a second time. Can someone help me to figure out what to do so that it(Text22) is updated each time the value in Dropdown8 is changed?

Code:
Sub Dropdown8_Click()
If ActiveDocument.FormFields("Dropdown8").Result = "Ogallala" Then
ActiveDocument.FormFields("Text22").Result = "SAR Model Needed"
Else
ActiveDocument.FormFields("Text22").Result = " "
End If
By Barry - 6/29/2009

I added

Application.ScreenUpdating = False
to the beginning of script event, and

Application.ScreenUpdating = True
to the end of the script event, which works as long as tab out before selecting another value.  But, if try to change value (of Dropdown8), without tabbing out, (Text22) does not update.