Form field lock up

A

Alain + Ivy

In a Word form, I have 2 fields which are both a dropdown list. The first
list is a Yes/No/Other and the other list is a 1 month/2 months/3
months....list.

I wish to make the "month" list locked up (impossible to select a value from
that list) when (and only when) "Other" is selected from the Yes/No/Other
list.

Is there a way to do that with VBA?

Alain Kadlec
Ottawa
 
J

Joost Verdaasdonk

Hai Alain,

No this is not possible!
Formfields don't have that property.

You could instead use a UserForm and play with the locked
property of a control!

Groetjes,
Joost Verdaasdonk
 
M

Martin Seelhofer

Hi Alain
I wish to make the "month" list locked up (impossible to select a value
from
that list) when (and only when) "Other" is selected from the Yes/No/Other
list.

Try setting the Enabled-property of the second one to False in a
macro which you set as the Exit-event-macro in dropdown 1.
You even can set the appropriate value of dropdown 2 using
its Result-property according to your needs.

Example:

1. add a single space (" ") as a value to the end of the second dropdown
list

2. add the following procedure to a VBA-module

Sub CheckListboxValue()
Dim lbx1 As FormField
Dim lbx2 As FormField
Set lbx1 = ActiveDocument.FormFields("Dropdown1") ' use your name
here
Set lbx2 = ActiveDocument.FormFields("Dropdown2") ' use your name
here
If lbx1.Result = "Other" Then
' select empty value (single space)
lbx2.Result = " "
' disable dropdown 2
lbx2.Enabled = False
Else

' re-enable dropdown 2
lbx2.Enabled = True
' select the first list entry
lbx2.Result = lbx2.DropDown.ListEntries(1).Name
End If
End Sub

3. choose the above proc as the macro to run when exiting dropdown 1

There you are ;-)


Cheers,
Martin
 
A

Alain + Ivy

Wow!
I am totally amazed.. Nothing is impossible with VBA...!!!
I wish to thanks a lot. You deserve more than that indeed...
I am going to try and I let you know. Alain
 

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