Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-21-2014, 07:58 AM
adamthepolak adamthepolak is offline Call value from previous form field Windows 7 64bit Call value from previous form field Office 2013
Novice
Call value from previous form field
 
Join Date: Jan 2014
Posts: 7
adamthepolak is on a distinguished road
Default Call value from previous form field

Hey there, im doing a form for physical assessments and have my first column as body location(A) and the second column(B) are the tests. once a location is selected from a drop down a list of test for that body region show up in the drop down field in the second column.
EX
A1 B1
A2 B2
I want to make it possible so that if formfield A2 is left at the default value formfield B2 loads the list associated with the value of A1. This is kind of what i want but the coding is not right

If formfield(A2).result = "default value" Then


formfield(A2) = formfield(A1).result
Reply With Quote
  #2  
Old 01-22-2014, 07:01 PM
macropod's Avatar
macropod macropod is offline Call value from previous form field Windows 7 32bit Call value from previous form field Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Since you're using Office 2013, I'd recommend eschewing formfields and using content controls. With these, some custom Quick Parts (building blocks) and a bit of code, you can have Word conditionally insert the desired dropdowns without having to code for populating them as well. Conditionally inserting & populating dropdown formfields takes a whole lot more work.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 01-24-2014, 09:40 PM
adamthepolak adamthepolak is offline Call value from previous form field Windows 7 64bit Call value from previous form field Office 2013
Novice
Call value from previous form field
 
Join Date: Jan 2014
Posts: 7
adamthepolak is on a distinguished road
Default

so how would one go about doing that? lol
Reply With Quote
  #4  
Old 01-25-2014, 04:39 AM
macropod's Avatar
macropod macropod is offline Call value from previous form field Windows 7 32bit Call value from previous form field Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

First, you would need to create each of your dependent dropdown content controls, each in its own paragraph. Then you would create a custom Quick Part from each of those paragraphs (see http://office.microsoft.com/en-us/wo...010370568.aspx). Next, you'd delete those from the document and create the dropdown you'll use to choose the various options. Then, insert a continuous Section break immediately before where the dependent dropdown is to be inserted. Finally, you'd add a macro to the document's 'ThisDocument' module, coded along the lines of:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim StrNm As String
With ContentControl
  If .Title <> "Dropdown 1" Then Exit Sub
  Select Case .Range.Text
    Case "Item 1": StrNm = "Fruit"
    Case "Item 2": StrNm = "Game"
    Case Else: StrNm = ""
  End Select
End With
With ActiveDocument.Sections(2).Range.ContentControls(1)
  .LockContentControl = False
  .Delete
End With
If StrNm = "" Then Exit Sub
Application.Templates("C:\Users\" & Environ("UserName") & _
  "\Documents\Misc\Office Config\Word\Normal.dotm"). _
  BuildingBlockEntries(StrNm).Insert RichText:=True, _
  Where:=ActiveDocument.Sections(2).Range.Characters.First
End Sub
where:
• "Dropdown 1" is the title property of the master dropdown
• "Item 1" & "Item 2" are the master dropdown entry names
• "Fruit" & "Game" are the corresponding custom Quick Part names.
• the custom Quick Parts are stored in Word's 'Normal' template.
• the target Section is Section 2.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 01-29-2014, 05:51 PM
adamthepolak adamthepolak is offline Call value from previous form field Windows 7 64bit Call value from previous form field Office 2013
Novice
Call value from previous form field
 
Join Date: Jan 2014
Posts: 7
adamthepolak is on a distinguished road
Default

thanks for the answer, but which part of the code addresses the issue of calling back to the previous value from cell A1 if A2 is blank?
Reply With Quote
  #6  
Old 01-30-2014, 07:34 PM
fumei fumei is offline Call value from previous form field Windows 7 64bit Call value from previous form field Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

Seems there is confusion between "formfield A2" and CELL A2. You asked about formfields NOT cells.
Reply With Quote
  #7  
Old 01-30-2014, 08:41 PM
adamthepolak adamthepolak is offline Call value from previous form field Windows 7 64bit Call value from previous form field Office 2013
Novice
Call value from previous form field
 
Join Date: Jan 2014
Posts: 7
adamthepolak is on a distinguished road
Default

Quote:
Originally Posted by fumei View Post
Seems there is confusion between "formfield A2" and CELL A2. You asked about formfields NOT cells.
My bad, yes i ment formfield, sorry im still new to the forums and have to make sure i use the proper wording
Reply With Quote
  #8  
Old 01-30-2014, 11:03 PM
macropod's Avatar
macropod macropod is offline Call value from previous form field Windows 7 32bit Call value from previous form field Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

As I advised in my previous reply:
Quote:
insert a continuous Section break immediately before where the dependent dropdown is to be inserted
With the code I posted, the assumption is that there will be a Section break immediately before wherever the dependent content control is to appear. There are other reference points one could use instead of a Section break, such as a table cell address, etc. The Section break is just for demonstration purposes.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Call value from previous form field Form field selection allows entry into form text box David C Word 1 10-24-2012 04:53 AM
Call value from previous form field Can't tab from field to field in form Lynieee Word 6 06-18-2012 02:37 PM
Word form field JBaker Word 18 03-22-2012 09:05 AM
Call value from previous form field Form Fields - Create blank form text field with if statement? LAssist2011 Word 5 12-14-2011 03:02 PM
Form Field Shading. Ninerhoss Word 0 11-23-2010 02:40 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:16 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft