Populating text boxes when checkbox selected

D

Debbiedo

I want to update some text boxes when a check box is selected.

I have 3 bookmarks labeled Text1, Text2 and Text3. When the user
selects the checkbox, a macro needs to be executed which populates
bookmarks TextA with data entered in bookmark Text1, TextB populated
with Text2 and TextC with Text3.

I need help with the macro or VBA script please.

I am using a MS Word 2003, protected form.

Thanks in advance, Deb
 
D

Doug Robbins - Word MVP

I assume that you are working with a form in a protected document. Instead
of using bookmarks at the locations of TextA, TextB and TextC, I would
insert DOCVARIABLE fields at those locations. Assuming that the fields
that you insert are { DOCVARIABLE VarA }, { DOCVARIABLE VarB } AND {
DOCVARIABLE VarC), then you would have a macro containing the following code
run on exit from the CheckBox:

With ActiveDocument
If .FormFields("Check1").CheckBox.Value = True then
.Variables("VarA").Value = .FormFields("Text1").Result
.Variables("VarB").Value = .FormFields("Text2").Result
.Variables("VarC").Value = .FormFields("Text3").Result
Else
.Variables("VarA").Value = " "
.Variables("VarB").Value = " "
.Variables("VarC").Value = " "
End If
.Range.Fields.Update
End With

--
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
 
D

Debbiedo

I assume that you are working with a form in a protected document. Instead
of using bookmarks at the locations of TextA, TextB and TextC, I would
insert DOCVARIABLE fields at those locations. Assuming that the fields
that you insert are { DOCVARIABLE VarA }, { DOCVARIABLE VarB } AND {
DOCVARIABLE VarC), then you would have a macro containing the following code
run on exit from the CheckBox:

With ActiveDocument
If .FormFields("Check1").CheckBox.Value = True then
.Variables("VarA").Value = .FormFields("Text1").Result
.Variables("VarB").Value = .FormFields("Text2").Result
.Variables("VarC").Value = .FormFields("Text3").Result
Else
.Variables("VarA").Value = " "
.Variables("VarB").Value = " "
.Variables("VarC").Value = " "
End If
.Range.Fields.Update
End With

--
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










- Show quoted text -

Will this work if the fields TextA, B and C need to be filled with
other data if the check box is NOT selected? Text1, 2 and 3 are home
address fields. If box is selected, pick up address (TextA, B, C) is
the same as home address and is populated (and ultimately geocoded).
If not, user has to populate TextA,B,C themselves.

I am sorry if I was not specific enough before. I don't always know I
did not include enough inormation until after I see the responses. In
my attempts to not be verbose I am sometimes too terse.

Thanks again

Deb
 
D

Doug Robbins - Word MVP

In that case, TextA, TextB and TextC should be Text FormFields and the code
you would run on exit from the CheckBox would be:

With ActiveDocument
If .FormFields("Check1").CheckBox.Value = True then
.FormFields("TextA").Result = .FormFields("Text1").Result
.FormFields("TextB").Result = .FormFields("Text2").Result
.FormFields("TextC").Result = .FormFields("Text3").Result
End If
End With


--
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
 

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