Dependant text entry

J

johnnykunst

I wasnt to automate a text entry on a form I'm working on; in a drop down list, the user selects a category and dependent on what they select, I want a text form field to populate with text (in this case a description of the category they have selected) So for example, if they select DRI from the drop down list, the text field populates with "Drug Related Information", if they select CASB the text field is populated with "Crime & Anti Social Behaviour"
I'm using Word 2003
Thanks to anyone who can help- have scoured the internet for a couple of hours but found nothing.
 
G

Graham Mayor

If your form will allow the use of macros then it is failrly simple to do
that - the process is more or less that described at
http://www.gmayor.com/SelectFile.htm, but while you can put the result in a
text form field, it might be better to apply it to a docvariable and use a
docvariable field - here {DocVariable "varText"} - to display the result as
in the second example Add as many case statements as you have entries in
your dropdown field

Sub OnExitDD1()
'fills text field based on content of _
dropdown field
Dim oFld As FormFields
Set oFld = ActiveDocument.FormFields
Select Case oFld("Dropdown1").Result
Case Is = "CASB"
oFld("Text1").Result = "Crime & Anti Social Behaviour"
Case Is = "Something else"
oFld("Text1").Result = "Text associated with something else"
Case Else
'Do nothing
End Select
End Sub

OR

Sub OnExitDD1()
Dim oFld As FormFields
Dim oVars As Variables
Set oFld = ActiveDocument.FormFields
Set oVars = ActiveDocument.Variables
Select Case oFld("Dropdown1").Result
Case Is = "CASB"
oVars("varText").Value = "Crime & Anti Social Behaviour"
Case Is = "Something Else"
oVars("varText").Value = "Text associated with something else"
Case Else
'Do nothing
End Select
ActiveDocument.Fields.Update
End Sub


If your form does not use macros then you can use a sequence of conditional
fields on the same line e.g.

{IF {REF Dropdown1} = "CASB" "Crime & Anti Social Behaviour"}{IF {REF
Dropdown1} = "Something Else" "The text associated with something else"}etc

This assumes the fieldname is Dropdown1 and that you have checked the
calculate on exit check box of the dropdown field to force an update to the
conditional field. Note that this won't work without macros if the fields
are in the document header/footer.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top