christy c


MS Word 2003.... I have a few text fields on a Word form. When the user clicks on TEXT_1, A macro popups a UserForm for user to select data. When the UserForm is closed, I display the user's selection in TEXT_1 and store a numeric value, such as "10" in TEXT_2 field. TEXT_2 is a hidden field (via font). The user do that a few times -- click on TEXT_3 and store numeric value in hidden TEXT_4 field.

At the end of the form, I have a TEXT_FINAL calculation field to display the total of (TEXT_2 + TEXT_4 + TEXT_6....). The problem is that the calculation doesn't happen. If I uncheck the "hidden" checkbox, it works fine.

I can't do calculation based on hidden text fields If so, how do I get around this I dont' want the user to see what's in TEXT_2 but need it for the FINAL calculation. Thanks for any help.




Re: Calculation based on hidden text fields on WORD form

ke wenzel


Hi christy c,

I don't know if there is a way to use hidden text fields or not, but why not unhide them in your program long enough to get their values, and then hide them again The user will never notice it.

Code Block

' assume txtVal1 and txtVal2 are hidden


Private Sub Ex1()
On Error GoTo Ex1_Err

Dim iTotal As Integer

txtVal1.Visible = True
txtVal2.Visible = True

iTotal = CInt(txtVal1) + CInt(txtVal2)

txtVal1.Visible = False
txtVal2.Visible = False

MsgBox "The total is " & CStr(iTotal)

Ex1_Exit:
Exit Sub

Ex1_Err:
MsgBox Err.Description
Resume Ex1_Exit

End Sub



KW





Re: Calculation based on hidden text fields on WORD form

christy c

Thanks KW. I am referring to the hiddlen field on the "cmdCloseForm" button on UserForm:

ActiveDocument.FormFields("TEXT_2").Visible = true

That's an invalid expression.... However the following works:

ActiveDocument.FormFields("TEXT_3").Select






Re: Calculation based on hidden text fields on WORD form

ke wenzel

Oops!

Sorry, I gave you MS Access code. I glad you got it to work though.

KW