dattagal
09-07-2006, 07:31 AM
Hi folks, I've been "nosing around" on this forum for a couple of days and have found a lot of interesting "stuff" but can't seem to find the answer to my specific problem so I will now post.
:banghead:
I have a Word form (Office 2000) on which I have 3 dropdowns:
a list of group offices [GODD] (for Group Office Drop Down)
a list of sales reps [SRDD]
a list of account assistants [AADD]I used (or tried to use) code I found from fumei (thank you fumei) but I keep getting the error message "data member not found".
I use VBA extensively in Access (well I use basically the same type of code modified extensively (mostly If -then statements)) but I cannot for the life of me get this Word VBA to work for me. (have never used a case statement before).
Anyway, I want the selection from the group office drop down (which for simplicity for now only has Atlanta, Chicago, Denver and San Francisco) to determine what names show up in the sales reps and account assistants drop downs.
Here is my code (probably a silly error on my part - I just have never been able to wrap my brain around a case statement).
Your assistance would be greatly appreciated!!
Thank you.
Sub FirstFieldExit()
Dim Atlanta(3) As String
Dim Chicago(5) As String
Dim Denver(2) As String
Dim i As Integer
Dim var
'Create your multiple lists here (dropdown #2)
Atlanta(0) = "Betty Boop"
Atlanta(1) = "Sponge Bob"
Atlanta(2) = "Katy Did"
Atlanta(3) = "Chatty Cathy"
Chicago(0) = "Superman"
Chicago(1) = "Superboy"
Chicago(2) = "Superwoman"
Chicago(3) = "Supergirl"
Chicago(4) = "Superdog"
Chicago(5) = "Supercat"
Denver(0) = "Pink Floyd"
Denver(1) = "Big Red"
Denver(2) = "Little Red"
'Use the value of the dropdown to case select condition
Select Case ActiveDocument.FormFields("Dropdown1").DropDown.Value
'For each one of these cases, change the ".Add Name:=" part to be
'one of the options in your #1 dropdown box
Case 1
ActiveDocument.FormFields("Result").DropDown.ListEntries.Clear
For var = 1 To 4
ActiveDocument.FormFields("Result").DropDown.ListEntries.Add Name:=Atlanta(i)
i = i + 1
Next
ActiveDocument.FormFields("Result").DropDown.Value = 1
Case 2
ActiveDocument.FormFields("Result").DropDown.ListEntries.Clear
For var = 1 To 4
ActiveDocument.FormFields("Result").DropDown.ListEntries.Add Name:=Chicago(i)
i = i + 1
Next
ActiveDocument.FormFields("Result").DropDown.Value = 1
Case 3
ActiveDocument.FormFields("Result").DropDown.ListEntries.Clear
For var = 1 To 4
ActiveDocument.FormFields("Result").DropDown.ListEntries.Add Name:=Denver(i)
i = i + 1
Next
ActiveDocument.FormFields("Result").DropDown.Value = 1
End Select
End Sub
ps: I don't have San Fransisco listed in the code b/c I want to use it as a testing tool - to see what happens when I select a value that is not included in the code.
:banghead:
I have a Word form (Office 2000) on which I have 3 dropdowns:
a list of group offices [GODD] (for Group Office Drop Down)
a list of sales reps [SRDD]
a list of account assistants [AADD]I used (or tried to use) code I found from fumei (thank you fumei) but I keep getting the error message "data member not found".
I use VBA extensively in Access (well I use basically the same type of code modified extensively (mostly If -then statements)) but I cannot for the life of me get this Word VBA to work for me. (have never used a case statement before).
Anyway, I want the selection from the group office drop down (which for simplicity for now only has Atlanta, Chicago, Denver and San Francisco) to determine what names show up in the sales reps and account assistants drop downs.
Here is my code (probably a silly error on my part - I just have never been able to wrap my brain around a case statement).
Your assistance would be greatly appreciated!!
Thank you.
Sub FirstFieldExit()
Dim Atlanta(3) As String
Dim Chicago(5) As String
Dim Denver(2) As String
Dim i As Integer
Dim var
'Create your multiple lists here (dropdown #2)
Atlanta(0) = "Betty Boop"
Atlanta(1) = "Sponge Bob"
Atlanta(2) = "Katy Did"
Atlanta(3) = "Chatty Cathy"
Chicago(0) = "Superman"
Chicago(1) = "Superboy"
Chicago(2) = "Superwoman"
Chicago(3) = "Supergirl"
Chicago(4) = "Superdog"
Chicago(5) = "Supercat"
Denver(0) = "Pink Floyd"
Denver(1) = "Big Red"
Denver(2) = "Little Red"
'Use the value of the dropdown to case select condition
Select Case ActiveDocument.FormFields("Dropdown1").DropDown.Value
'For each one of these cases, change the ".Add Name:=" part to be
'one of the options in your #1 dropdown box
Case 1
ActiveDocument.FormFields("Result").DropDown.ListEntries.Clear
For var = 1 To 4
ActiveDocument.FormFields("Result").DropDown.ListEntries.Add Name:=Atlanta(i)
i = i + 1
Next
ActiveDocument.FormFields("Result").DropDown.Value = 1
Case 2
ActiveDocument.FormFields("Result").DropDown.ListEntries.Clear
For var = 1 To 4
ActiveDocument.FormFields("Result").DropDown.ListEntries.Add Name:=Chicago(i)
i = i + 1
Next
ActiveDocument.FormFields("Result").DropDown.Value = 1
Case 3
ActiveDocument.FormFields("Result").DropDown.ListEntries.Clear
For var = 1 To 4
ActiveDocument.FormFields("Result").DropDown.ListEntries.Add Name:=Denver(i)
i = i + 1
Next
ActiveDocument.FormFields("Result").DropDown.Value = 1
End Select
End Sub
ps: I don't have San Fransisco listed in the code b/c I want to use it as a testing tool - to see what happens when I select a value that is not included in the code.