Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How do you add an IF statement to a user form field?
I want to create a simple form to enter answers to 20 or so questions. How
do I lock a field (so the user cannot manually return and enter a value) if the previous entry was "no" and then jump to the next series of questions For example: ----- Have you talked to accounting? [TalkedToAccounting] (drop down box -- yes/no) IIF TalkedToAccounting = yes THEN go to [AccountantsName] ELSE lock [AccountantsName] lock [AccountantsAnswer] go to [LegalQuestions] END IF If so, which Accountant did you talk to? [AccountantsName] What did the Account tell you? [AccountantsAnswer] .. . . [LegalQuestions] ----- I'd sincerely appreciate any suggestions on how I could implement that logic within form fields. Very respectfully, Larry I"d like to lock the |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How do you add an IF statement to a user form field?
This could be tricky to implement and will rely on ensuring that users will
allow macros to run and that users tab out of the field. In which case run the following macro on exit from the dropdown field Dim sPassword As String sPassword = "" 'password to protect/unprotect form With ActiveDocument .Unprotect Password:=sPassword If LCase(.FormFields("TalkedToAccounting").Result) = "yes" Then .FormFields("AccountantsName").Select With Dialogs(wdDialogFormFieldOptions) .Enable = True .Execute End With .FormFields("AccountantsAnswer").Select With Dialogs(wdDialogFormFieldOptions) .Enable = True .Execute End With .FormFields("AccountantsName").Select Else .FormFields("AccountantsName").Select With Dialogs(wdDialogFormFieldOptions) .Enable = False .Execute End With .FormFields("AccountantsAnswer").Select With Dialogs(wdDialogFormFieldOptions) .Enable = False .Execute End With .FormFields("LegalQuestions").Select End If .Protect NoReset:=True, Password:=sPassword, _ Type:=wdAllowOnlyFormFields End With http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Larry Root wrote: I want to create a simple form to enter answers to 20 or so questions. How do I lock a field (so the user cannot manually return and enter a value) if the previous entry was "no" and then jump to the next series of questions For example: ----- Have you talked to accounting? [TalkedToAccounting] (drop down box -- yes/no) IIF TalkedToAccounting = yes THEN go to [AccountantsName] ELSE lock [AccountantsName] lock [AccountantsAnswer] go to [LegalQuestions] END IF If so, which Accountant did you talk to? [AccountantsName] What did the Account tell you? [AccountantsAnswer] . . . [LegalQuestions] ----- I'd sincerely appreciate any suggestions on how I could implement that logic within form fields. Very respectfully, Larry I"d like to lock the |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How do you add an IF statement to a user form field?
Graham, Thank you very much for your solution. Unfortunately, I'm working with very well educated individuals who all want to do it their way; we end up iterating several times through the questions because they won't "waste time" on such mundane tasks as reading a single sentence of directions. So I'm afraid that I cannot assume that they'll either follow directions to tab out of the field or wait for the macro to complete, which is why I'm trying to restrict their discretion. Rather than a simple, single sheet form, I'll look into using different form modules and sequence the modules with logic to expose them to only what they need to do next. VERY respectfully, Larry "Graham Mayor" wrote: This could be tricky to implement and will rely on ensuring that users will allow macros to run and that users tab out of the field. In which case run the following macro on exit from the dropdown field Dim sPassword As String sPassword = "" 'password to protect/unprotect form With ActiveDocument .Unprotect Password:=sPassword If LCase(.FormFields("TalkedToAccounting").Result) = "yes" Then .FormFields("AccountantsName").Select With Dialogs(wdDialogFormFieldOptions) .Enable = True .Execute End With .FormFields("AccountantsAnswer").Select With Dialogs(wdDialogFormFieldOptions) .Enable = True .Execute End With .FormFields("AccountantsName").Select Else .FormFields("AccountantsName").Select With Dialogs(wdDialogFormFieldOptions) .Enable = False .Execute End With .FormFields("AccountantsAnswer").Select With Dialogs(wdDialogFormFieldOptions) .Enable = False .Execute End With .FormFields("LegalQuestions").Select End If .Protect NoReset:=True, Password:=sPassword, _ Type:=wdAllowOnlyFormFields End With http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Larry Root wrote: I want to create a simple form to enter answers to 20 or so questions. How do I lock a field (so the user cannot manually return and enter a value) if the previous entry was "no" and then jump to the next series of questions For example: ----- Have you talked to accounting? [TalkedToAccounting] (drop down box -- yes/no) IIF TalkedToAccounting = yes THEN go to [AccountantsName] ELSE lock [AccountantsName] lock [AccountantsAnswer] go to [LegalQuestions] END IF If so, which Accountant did you talk to? [AccountantsName] What did the Account tell you? [AccountantsAnswer] . . . [LegalQuestions] ----- I'd sincerely appreciate any suggestions on how I could implement that logic within form fields. Very respectfully, Larry I"d like to lock the |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How do you add an IF statement to a user form field?
You can overcome the tabbing issue by validating the form fields - see
http://www.gmayor.com/formfieldmacros.htm and there are some examples on my web site http://www.gmayor.com/word_vba_examples.htm which show how to insert sections of forms as required by the data filled so far. Education however is no substitute for common sense -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Larry Root wrote: Graham, Thank you very much for your solution. Unfortunately, I'm working with very well educated individuals who all want to do it their way; we end up iterating several times through the questions because they won't "waste time" on such mundane tasks as reading a single sentence of directions. So I'm afraid that I cannot assume that they'll either follow directions to tab out of the field or wait for the macro to complete, which is why I'm trying to restrict their discretion. Rather than a simple, single sheet form, I'll look into using different form modules and sequence the modules with logic to expose them to only what they need to do next. VERY respectfully, Larry "Graham Mayor" wrote: This could be tricky to implement and will rely on ensuring that users will allow macros to run and that users tab out of the field. In which case run the following macro on exit from the dropdown field Dim sPassword As String sPassword = "" 'password to protect/unprotect form With ActiveDocument .Unprotect Password:=sPassword If LCase(.FormFields("TalkedToAccounting").Result) = "yes" Then .FormFields("AccountantsName").Select With Dialogs(wdDialogFormFieldOptions) .Enable = True .Execute End With .FormFields("AccountantsAnswer").Select With Dialogs(wdDialogFormFieldOptions) .Enable = True .Execute End With .FormFields("AccountantsName").Select Else .FormFields("AccountantsName").Select With Dialogs(wdDialogFormFieldOptions) .Enable = False .Execute End With .FormFields("AccountantsAnswer").Select With Dialogs(wdDialogFormFieldOptions) .Enable = False .Execute End With .FormFields("LegalQuestions").Select End If .Protect NoReset:=True, Password:=sPassword, _ Type:=wdAllowOnlyFormFields End With http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Larry Root wrote: I want to create a simple form to enter answers to 20 or so questions. How do I lock a field (so the user cannot manually return and enter a value) if the previous entry was "no" and then jump to the next series of questions For example: ----- Have you talked to accounting? [TalkedToAccounting] (drop down box -- yes/no) IIF TalkedToAccounting = yes THEN go to [AccountantsName] ELSE lock [AccountantsName] lock [AccountantsAnswer] go to [LegalQuestions] END IF If so, which Accountant did you talk to? [AccountantsName] What did the Account tell you? [AccountantsAnswer] . . . [LegalQuestions] ----- I'd sincerely appreciate any suggestions on how I could implement that logic within form fields. Very respectfully, Larry I"d like to lock the |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Form field in conditional statement | Microsoft Word Help | |||
Form Date Field- Does user have to type separators? | Microsoft Word Help | |||
How can a user change the default date in a form field? | Tables | |||
Adding Autotext in a Macro User Form field | Microsoft Word Help | |||
allow user to add text to an already existing form list field | Microsoft Word Help |