Log in

View Full Version : Word - conditional drop down fields



arcanedevice
07-21-2008, 07:19 PM
Hi
I'm very new to all of this but find it fascinating and enjoyable to learn, and hopefully someone can assist - I have been trying to use Fumei's excellent guide to creating conditional drop down menus in Word, but keep getting bug errors.
I have even tried using the exact same code as Fumei provided in the example but it still doesn't work for me. Does anyone know where I might be going wrong?

OTWarrior
07-22-2008, 12:57 AM
As an alternative, have you tried my KB entry for generating multiple lists on a dropdown to bypass the 25 limit? The code I have on there is conditional also, and changes the current dropdown form field.

http://vbaexpress.com/kb/getarticle.php?kb_id=968

arcanedevice
07-22-2008, 05:51 PM
Hi

Yeah, I actually found that yesterday after I put my post up because that is the next thing I wanted to try. :thumb

Will be working on this again tomorrow so will let you know if I encounter any difficulties...

arcanedevice
08-05-2008, 11:03 PM
Hi Again!

I found your code above really helpful, but now that I'm getting used to playing with it I'm wondering how do I allow it to generate three lists? In particular, where is (or what is) the code that I add that will allow the User to move back to the first list or forwards to a third list etc.

OTWarrior
08-05-2008, 11:55 PM
I am glad you found it to be helpful :D

This part checks the value of the dropdown formfield (note you can have multiple elseif statements for every value)

this is only part of the code, as this is all you need to change to get it working.

as far as I know (haven't tried) you can have as many arrays of data as you like, and can call them from anywhere.

For example, in a project I used this code for, I started off with a main list showing the area (north south west) then based on those options, create a new list for the type (high low medium, for that area), then created the final list.

eg:


Dim Data1 As Variant
Data1 = Array("This", "Works", "Rather", "Well", "Wouldn't", "You", "Say?", "List2", "List 3")
Dim Data2 As Variant
Data2 = Array("Data1", "Data2", "Data3", "Data4", "List1", "List 3")
Dim Data3 As Variant
Data3 = Array("badger","mushroom","Snake", "List1", "List 2")

ElseIf ffSelect.Result = "List 1" Then
'rebuild formfield with data from data1

ffSelect.Select
With ffSelectList
.Clear
.Add "Select an Option"
Application.DisplayStatusBar = True
Application.StatusBar = "Please wait while Word rebuild the dropdown list..."
For i = LBound(Data1) To UBound(Data1)
.Add Data1(i)
Next i
End With
ffSelectDropdown.Value = 1
nGenCount = True
Application.DisplayStatusBar = False
Call Highlighter
DoEvents
SendKeys "%({DOWN})", True
Call ffGenerator

ElseIf ffSelect.Result = "List 2" Then
'rebuild formfield with data from data2

ElseIf ffSelect.Result = "List 3" Then
'rebuild formfield with data from data3

Here is a demo of how it works...