• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 565
  • Last Modified:

Word 2010 - checkboxes with automatic autofil

Hello All:

I'm creating an Word Document and have 7 separate tables ( 1 table attached for reference ).  I am using 'autofield' for the auto fill so after the separate 7 tables ; It would autosum to equal on an separate table.  

My problem is I have checkboxes that when checked, need to update the 'autofield' with the appropriate number. I've used multiple macros & nothing worked so I've deleted all macros and starting fresh so any help would be greatly appreciated.  

I've also attached 2 examples.
attachment.png = Orange circle is autofield needed for autosum
example1.png = Checked 5 and autofilled #5
example2.png = Checked 3 and autofilled #3
attachment.PNG
example1.PNG
example2.PNG
0
synertia
Asked:
synertia
1 Solution
 
GrahamSkanCommented:
It is difficult to be sure from your description and just pictures, but I am guessing that you are using form fields.

If you change the bookmark names of the fields to something like quantity_5, quantity_4 etc., you can use a macro like this and set it to be the exit macro for each of the checkboxes.
Sub FillField()
Dim ffldCheck As FormField
Dim ffldText As FormField
Dim strName  As String
Dim strNumber As String

Set ffldCheck = Selection.FormFields(1)
strName = Split(ffld1.Name, "_")(0)
strNumber = Split(ffld1.Name, "_")(1)

Set ffldText = ActiveDocument.FormFields(strName)

If ffldCheck.CheckBox.Value = True Then
    ffldText.Result = strNumber
Else
    ffldText.Result = ""
End If

End Sub

Open in new window

0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now