Form field completion

M

Mark

I am using Word 2003.

I have a document with formfields throughout the but because of the number
of options in some of the dropdowns I have had to call a form to populate
some of the fields(which are repeated several times throughout the document).

The following code identifies the field and is supposed to poplulate that
particular field, but it doesn't always work and populates a totally
different field at the begining of the document!


Private Sub ComboBox1_Change()
Dim sDivision As String

If Selection.FormFields.Count = 1 Then

'No textbox but a check- or listbox
'MsgBox Selection.FormFields(1).Name

ElseIf Selection.FormFields.Count = 0 And Selection.Bookmarks.Count > 0 Then

sDivision = Selection.Bookmarks(Selection.Bookmarks.Count).Name
End If

ActiveDocument.FormFields(sDivision).Result = ComboBox1.Value

Unload Me

ActiveDocument.FormFields(sDivision).Next.Select

End Sub


Can anyone assistme with a solution, please?

Thanks in advance.
 
D

Doug Robbins - Word MVP on news.microsoft.com

I would try having the code that calls the userform get the name of the
formfield from which it is called, rather than using the code in the
userform to do it.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
Top