Hide a row in a table based upon a previous selection

D

dworst

I have a Word 2003 form. There are multiple tables on the form. What
I want to do is to hide a selection of text in table #3, Row 27 if a
selection in Table 1, row 1, field10 is greater than 5 characters and
show another row of text.

I've looked through the postings and have not found anything quite like
this.

Can anyone help me out with some code?

Thanks so much!
 
D

Doug Robbins - Word MVP

You could run a macro on exit from Field 10 and gets the .Result of that
formfield and depending upon it's length, set the font in Row 27 of table 3
as hidden. I am not sure where the other row of text enters into this.

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

dworst

I have a Word 2003 form. There are multiple tables on the form. What
I want to do is to hide a selection of text in table #3, Row 27 if a
selection in Table 1, row 1, field10 is greater than 5 characters and
show another row of text.

I've looked through the postings and have not found anything quite like
this.

Can anyone help me out with some code?

Thanks so much!

Oh and by the way, the form is protected. As I'm working through
trying to create this code it keeps giving me an error saying that the
section I have in the code is protected.

I really need some help on this.....anybody have any suggestions
 
D

Doug Robbins - Word MVP

You will have to include

ActiveDocument.Unprotect

and then later

ActiveDocument.Protect wdAllowOnlyFormFields, NoReset

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

dworst

Doug:

Ok here is my code so far. What I'm trying to do is: if the zip code
form field is more than 5 digits (which is so for Canada) then hide
rows 22, 23 and 29 but if it is a USA zip code 5 digits, then show rows
22,23 and 29 and hide row 21.

Can you help me out as my code isn't working. Thanks a bunch!

Public Sub CanadaZipCode()

If ActiveDocument.FormFields("zipcode").Result <= 5 Then
ActiveDocument.Unprotect
ActiveDocument.Tables(3).Rows(21).Range.Font.Hidden = True
ActiveDocument.Tables(3).Rows(22).Range.Font.Hidden = False
ActiveDocument.Tables(3).Rows(23).Range.Font.Hidden = False
ActiveDocument.Tables(3).Rows(29).Range.Font.Hidden = False
ActiveDocument.Protect wdAllowOnlyFormFields, NoReset
Else
If ActiveDocument.FormFields("zipcode").Result > 5 Then
ActiveDocument.Unprotect
ActiveDocument.Tables(3).Rows(21).Range.Font.Hidden = False
ActiveDocument.Tables(3).Rows(22).Range.Font.Hidden = True
ActiveDocument.Tables(3).Rows(23).Range.Font.Hidden = True
ActiveDocument.Tables(3).Rows(29).Range.Font.Hidden = True
ActiveDocument.Protect wdAllowOnlyFormFields, NoReset



End If
End If

End Sub
 
D

Doug Robbins - Word MVP

ActiveDocument.FormFields("zipcode").Result <= 5 is not going to work.

Len(ActiveDocument.FormFields("zipcode").Result ) <= 5

will probably work as it will give you the length of the result.

It may however be better to use the IsNumeric() function as US Zip Codes are
numeric whereas Canadian ones are alpha-numeric.

Even in that case however, probably better to use

IsNumeric(Left(ActiveDocument.FormFields("zipcode").Result, 5)

as that will pickup 9 digit US Zip Codes (#####-####) which IsNumeric() by
itself may miss.
--
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