drop down box help please

  • Thread starter Thread starter Kim K
  • Start date Start date
K

Kim K

I have a word doc with one drop down that I would like to do as follows: If
the user drops down the box and the answer is A,b or C then it will take them
to the next field to further clarify the answer and they can not move forward
until that is answered. IF the answer is D or E they can skip the next field
for further clarification. I hope this makes sense. Can anyone help please?
 
You need to have macros set to run on exit from your Dropdown field and
mandatory text field (MyDropDown and MyText in my example), and on entry to
all fields. MyText2 is the field after your mandatory text field.

Option Explicit
Public mstrFF As String
Public Sub AOnExit()
Dim oDoc As Word.Document
Set oDoc = ActiveDocument
With GetCurrentFF
Select Case .Name
Case Is = "MyDropDown"
Select Case .Result
Case Is = "A", "B", "C"
ActiveDocument.FormFields("MyText").Enabled = True
ActiveDocument.Bookmarks("MyText").Range.Fields(1).Result.Select
Case Else
ActiveDocument.FormFields("MyText").Result = ""
ActiveDocument.FormFields("MyText").Enabled = False
ActiveDocument.Bookmarks("MyText2").Range.Fields(1).Result.Select
End Select
Case Is = "MyText"
If Len(.Result) < 1 Then
mstrFF = .Name
End If
End Select
End With
End Sub
Public Sub AOnEntry()
Dim strCurrentFF As String
If LenB(mstrFF) > 0 Then
ActiveDocument.Bookmarks(mstrFF).Range.Fields(1).Result.Select
mstrFF = vbNullString
End If
End Sub

Public Function GetCurrentFF() As Word.FormField
With Selection
If .FormFields.Count = 1 Then
Set GetCurrentFF = .FormFields(1)
ElseIf .FormFields.Count = 0 And .Bookmarks.Count > 0 Then
Set GetCurrentFF = ActiveDocument.FormFields _
(.Bookmarks(.Bookmarks.Count).Name)
End If
End With
End Function
 
ok I think I am seeing where this is going but I Need some help if you can
please clarify.

On the drop down box, I need to bookmarkit as MYDropDown? I set the macro
to run on entry as AOnOpen and on exit as AOnExit?

The field that I want to go to is a Legacy Text Form Field? It is
bookmarked as MyTest or My TExt2?

It is set to run on Entry and exit as AOnOpen and AOnExit as well?

Thanks in advance.
 
Kim,

You set the AOnExit macro run on the two fields that you want to validate or
act on. In this case it would be the dropdown (bookmark it as you wish and
change the code accordingly) and the textfield that can't be blank if ABC is
selected in the dropdown. Again, bookmark as you wish and change the code
accordingly. The AOnEntry macro should be set to run on entry to all
fields.

The way it is set up is that if A B or C is selected the the mandatory text
field is enabled. If D or E is selected then the mandatory text field is
disabled and skipped and the following field is selected.
 

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

Back
Top