View Single Post
 
Old 05-08-2010, 06:02 AM
gmaxey gmaxey is online now Windows XP Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

First let me say that I know how much submariners love to be inspected so perhaps I shouldn't do more to make it easier on your shop .

That said, I also know that submariners don't always appreciate what is best for them so:

The first thing you need to do is to assign meaningful bookmark names to your formfields. Continuing from the previous example, lets name the checkbox VT_DIM and the text field B11_1 (That is for block 11, field 1 and perhaps not so meaningful).

You could simply create another OnExit macro specifically for the checkbox, but if this is something you want to fully exploit then you should use a single OnExit macro. Something like this:

Sub FormFieldOnExit()
Dim oFF As FormFields
Set oFF = ActiveDocument.FormFields
Dim pName As String
pName = FieldID
Select Case pName
Case "Name"
Select Case oFF(pName).Result
Case "TOPEKA"
oFF("UIC").Result = "12345"
Case "PASADENA"
oFF("UIC").Result = "54321"
Case "HELENA"
oFF("UIC").Result = "99999"
End Select
Case "VT_DIM"
Select Case oFF("VT_DIM").CheckBox.Value
Case "True"
oFF("B11_1").Result = "1C"
Case Else
oFF("B11_1").Result = ""
End Select
End Select
End Sub
Function FieldID() As String
Dim pFldName As String
If Selection.FormFields.Count = 1 Then
pFldName = Selection.FormFields(1).Name
ElseIf Selection.FormFields.Count = 0 And Selection.Bookmarks.Count > 0 Then
pFldName = Selection.Bookmarks(Selection.Bookmarks.Count).Nam e
End If
FieldID = pFldName
End Function
Reply With Quote