Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FORMS auto populate / if then routine

Status
Not open for further replies.

DRUDUDE

Technical User
Jan 26, 2010
1
BM
Hi guys first time posting,
I own a business that does in depth estimates and quotes for our clients. they are currently done on forms by hand. I am trying to transfer it to a handheld unit. Thus i would like to create a form in MS word 2003 that my guy can just tick and email back to the office.

1)i am wondering if there is a way to include "IF Then" routines into the form. i.e. If boat is over 10' (in field 1) then (field 3) will populate with "size 3 shackles" automatically.

2) is there also a way to get two documents talking the same way. ie. my field agent ticks x on form one. and it somehow changes value y on form 2?

Thanks,
Dru
 
Yes, and yes. I am sorry I can not give more details, as there is not enough details in your post. But....

1. assuming these are formfields (and I do not know for sure they are....), for example, you could use an OnExit macro like:
Code:
Sub FillInShackles()
Select Case ActiveDocument.FormFields("BoatLength").Result
   Case " <10"
      ActiveDocument.FormFields("ShackleSize").Result _
         = " really small"
   Case " 10 - 15"
      ActiveDocument.FormFields("ShackleSize").Result _
         = " size 3 shackles"
   Case " >15"
         ActiveDocument.FormFields("ShackleSize").Result _
         = " really BIG"
End Select
End Sub

A dropdown formfield ("Boatlength") has an OnExit like above. User selects " 10 - 15" from the dropdown, and tabs out. The OnExit macro fires and puts " size 3 shackles" in the text formfield "ShackleSize".

2. you could try using INCLUDETEXT fields.

Some notes regarding INCLUDETEXT:

1. Say the source file is c:\Gerry\FromSource.doc.

{ INCLUDETEXT "c:\\Gerry\\FromSource" ShackleSize \* MERGEFORMAT }

would show the bookmark as a bookmark.

{ INCLUDETEXT "c:\\Gerry\\FromSource.doc" ShackleSize \* MERGEFORMAT }

would show the bookmark as only text.

In other words, while both field codes gets the bookmark "ShackleSize" from the file "FromSource.doc", the first gets the actual bookmark, the second does not.

2. in BOTH cases, if the bookmark - ShackleSize - refers to a formfield - it returns.....NOTHING. It will be blank.

There may indeed be a value in the formfield, say "size 3 shackles", but that will NOT - repeat NOT - be carried over by the INCLUDETEXT field.

Why? Because of the confusion people have between formfields and bookmarks. Formfields have bookmarks, but they are not bookmarks themselves. Unfortunately INCLUDETEXT only looks at bookmarks. The value - the text "size 3 shackles" is the Result property of the formfield.

A) Selection.TypeText ActiveDocument.Bookmarks("ShackleSize") _
.Range.Text

B) Selection.Typetext ActiveDocument.Formfields("ShackleSize") _
.Result

Even though it may appear the reference is to the same thing, they are NOT:

Results?

A) FORMTEXT size 3 shackles
B) size 3 shackles

So, in theory, again, the answer to your questions:

yes
yes

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top