Conditional Macro

T

Travis G.

Very little knowledge of how to do this, but I've been learning. I'm creating
a form that works for 25 forms. If user selects form 101 from a list, they
only see the droplist they would need. I found a code that works in a similar
manor, just not exactly. It was writen to say, if i select "A", I only see
subcatagory "1" &"2". If I select "B", I only see "2" & "3". I need one to
Select "101" and see the five different list associated with that. Select
"102", see the five list associated with that and so on...... Please help, I
know there are plenty of smart people out there who can do this in thier
sleep.


Sub PopulateSubCat()
Dim oFld As FormFields
Set oFld = ActiveDocument.FormFields
Select Case oFld("form").Result
Case Is = "test1"
With oFld("number").DropDown
..ListEntries.Clear
..ListEntries.Add "101"
..ListEntries.Add "102"
..Value = 1
End With
Case Is = "test2"
With oFld("number").DropDown
..ListEntries.Clear
..ListEntries.Add "103"
..Value = 1
End With

End Select
End Sub
 
D

Doug Robbins - Word MVP

If you have two DropDown FormFields (DropDown1 and DropDown2) with DropDown1
containing the items 101 and 102, if you run a macro containing the
following code on exit from DropDown1, it will populate the list in
DropDown2 with the entries associated with the item selected in DropDown1

Dim oFld As FormFields
Set oFld = ActiveDocument.FormFields
Select Case oFld("DropDown1").result
Case Is = "101"
With oFld("DropDown2").DropDown
.ListEntries.Clear
.ListEntries.Add "101-Item1"
.ListEntries.Add "101-Item2"
.ListEntries.Add "101-Item3"
.ListEntries.Add "101-Item4"
.ListEntries.Add "101-Item5"
.Value = 1
End With
Case Is = "102"
With oFld("DropDown2").DropDown
.ListEntries.Clear
.ListEntries.Add "102-Item1"
.ListEntries.Add "102-Item2"
.ListEntries.Add "102-Item3"
.ListEntries.Add "102-Item4"
.ListEntries.Add "102-Item5"
.Value = 1
End With
End Select


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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