Copy Mutually Exclusive Checkbox to Summary Page

S

Sam Schroder

I have the following code to validate a row of checkboxes (customer wants checkboxes; not radio buttons). It makes sure that the boxes in the row (5 boxes in a row) are mutually exclusive, then copies the results to a summary page. I have set up the checkboxes with Entry macro as below and "calculate on exit". The code works, but there seems to be a lot of "chugging" going on. Since I am brand new to Word macros, I'm wondering if maybe the code is not the efficient way to do it. If someone could tell me if I'm on the right track, or should be doing something differently....

Dim objField As FormField
Dim curName As String
Dim sumName As String
'
' First set all checkboxes in the row to false
For Each objField In Selection.Rows(1).Range.FormFields
If objField.Type = wdFieldFormCheckBox Then
objField.CheckBox.Value = False
End If
Next objField
'
' Now set the selected box to a check mark
Selection.FormFields(1).CheckBox.Value = True
'
' Get the base name for the current field
' and the corresponding summary field
curName = Mid(Selection.FormFields(1).Name, 1, 4)
sumName = curName & "Sum"
'
' Transfer the final values to the summary page
For i = 1 To 5
ActiveDocument.FormFields(sumName & i).CheckBox.Value = ActiveDocument.FormFields(curName & i).CheckBox.Value
Next i

EggHeadCafe - Software Developer Portal of Choice
C# Dev Guide to ASP.NET/ADO.NET/XML
http://www.eggheadcafe.com/tutorial...b75c-62447b32e36f/c-dev-guide-to-aspneta.aspx
 
J

Jay Freedman

That's the recommended code (similar to
http://www.word.mvps.org/FAQs/TblsFldsFms/ExclusiveFmFldChbxs.htm).
You could try to hide the "chugging" by setting
Application.ScreenUpdating = False at the start and = True at the end.

The real solution is to replace the set of checkboxes with a single
dropdown form field. By definition a dropdown allows only one value to
be selected. I don't know how your customer will feel about that,
though.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
S

Sam Schroder

Thanks Jay. Just wanted to be sure since this is new to me.

You are correct. I got the gist of the code from the item you referenced. Added a little code from another item.

This forum has been a great help!

Thanks again.



Jay Freedman wrote:

That's the recommended code (similar
09-Oct-09

That's the recommended code (similar to
http://www.word.mvps.org/FAQs/TblsFldsFms/ExclusiveFmFldChbxs.htm).
You could try to hide the "chugging" by setting
Application.ScreenUpdating = False at the st

Previous Posts In This Thread:

EggHeadCafe - Software Developer Portal of Choice
Make Your ASP.NET Mobile Forms Timer - Refresh
http://www.eggheadcafe.com/tutorial...a68-72d2c53b8470/make-your-aspnet-mobile.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top