I'd say you're right Jay. This is similar to what I do in a UserForm that
has a similar requirement. In my case, I have a Registered Address and a
Service Address, and there's a checkbox to indicate that the Service Address
is the same as the Registered Address. If the checkbox is selected, then I
want to copy the values from the Registered Address details into the Service
Address details and disable the Service Address details so they can't be
modified. And if the checkbox is subsequently cleared, I want to 'reset' and
re-enable the Service Address details to allow direct entry. My code looks
like this:
[snip code]
(It's maybe a bit more 'modular' than would be strictly necessary in most
applications, but I've done it this to meet certain other requirements that
most people don't have.)
Then on the document side, I just insert whatever is in the various
textboxes on the UF into corresponding bookmarks - not that it really
matters for "Britt". The point is that my approach is very similar to what
you're recommending for use with form fields. The one thing that might be
missing from your approach is a step to 'reset' the Billing Address form
fields if the user goes back and clears the checkbox again. Something like:
.Item("BillAddr").Enabled = True '<--- from Jay's code
.Item("BillAddr").Result = "" '<--- add this line for each form field
should do the trick.
--
Cheers!
Gordon Bentley-Mix
Jay Freedman said:
Doug, I don't think any of the techniques on Greg's page will apply
here, since the Billing fields should operate independently when the
check box is unchecked.
Instead, I'd suggest writing an exit macro for the check box that
looks at the state of the check box and takes one of two sets of
actions:
- If the box is checked, copy the content of each "physical address"
field to the corresponding "billing address" field, and set Enabled =
False for each billing field so it can't be edited.
- If the box is unchecked, set Enabled = True for each "billing
address" field. (That way, if the user changes the box from checked to
unchecked, the billing fields can be edited again.)
The macro would look something like this:
Sub ExitCheck()
With ActiveDocument.FormFields
If .Item("CheckSame").CheckBox.Value = True Then
.Item("BillAddr").Result = .Item("PhysAddr").Result
.Item("BillAddr").Enabled = False
' repeat these two lines for other fields
Else
.Item("BillAddr").Enabled = True
' repeat this line for other fields
End If
End With
End Sub
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.