Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2005

Tip: Looking for answers? Try searching our database.

Need help with Word form macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kim17740 - 02 Aug 2005 17:16 GMT
Here's the setup... I have a form that has a drop down list field.  When the
user selects "other" from the list I want them to be automatically directed
to the next blank text field where they will have to enter what "other" is.

I've never been good at setting up macros so any help will be greatly
appreciated.

Thanks.
Jean-Guy Marcil - 02 Aug 2005 19:14 GMT
Kim17740 was telling us:
Kim17740 nous racontait que :

> Here's the setup... I have a form that has a drop down list field.
> When the user selects "other" from the list I want them to be
[quoted text clipped - 3 lines]
> I've never been good at setting up macros so any help will be greatly
> appreciated.

Perhaps something along those lines:

'_______________________________________
With ActiveDocument.FormFields
   If Selection.Range.FormFields(1).Result = "Other" Then
       .Item("otherTxt").Enabled = True
       .Item("otherTxt").Range.Fields(1).Result.Select
   Else
       .Item("otherTxt").Enabled = False
       .Item("skipTxt").Range.Fields(1).Result.Select
   End If
End With
'_______________________________________

Just change "otherTxt" and "skipTxt" for your target text fields.

Note that I disabled the "Other" text fields whenever the dropdown value is
not "Other". This way the user cannot inadvertently enter a value that is
not necessary or that could be misleading (If "Other" is *not* selected, but
a text is entered in the "Other" text field, where is the error? Is the
error in the text field or the drop down? This way, you do not have to
worry. You could even add code to set the "Other" text field to an empty
string whenever something other than "Other" is selected in the dropdown:

'_______________________________________
With ActiveDocument.FormFields
   If Selection.Range.FormFields(1).Result = "Other" Then
       .Item("otherTxt").Enabled = True
       .Item("otherTxt").Range.Fields(1).Result.Select
   Else
       .Item("otherTxt").Result = ""
       .Item("otherTxt").Enabled = False
       .Item("skipTxt").Range.Fields(1).Result.Select
   End If
End With
'_______________________________________

Better be proactive regarding user errors because Murphy's law absolutely
applies in those situations...

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.