type mismatch error?

A

Angyl

I'm moving data inputted into a userForm to Form Fields in a word document
and I need to multiply some of the data by 12 (because I'm going from monthly
to yearly amounts). This code:

..FormFields("txtAnnualGross1").Result = WCInfo.txtMonthlyGross1

Does the job just fine of getting the base, (entered as monthly gross) into
the form field, but when I try:

..FormFields("txtAnnualGross1").Result = WCInfo.txtMonthlyGross1 * 12

I get a type mismatch error. How do I get this thing to let me multiply the
result by 12 before putting it in the form?
 
J

Jonathan West

Angyl said:
I'm moving data inputted into a userForm to Form Fields in a word document
and I need to multiply some of the data by 12 (because I'm going from
monthly
to yearly amounts). This code:

.FormFields("txtAnnualGross1").Result = WCInfo.txtMonthlyGross1

Does the job just fine of getting the base, (entered as monthly gross)
into
the form field, but when I try:

.FormFields("txtAnnualGross1").Result = WCInfo.txtMonthlyGross1 * 12

I get a type mismatch error. How do I get this thing to let me multiply
the
result by 12 before putting it in the form?

Do your type conversions explicitly, like this

.FormFields("txtAnnualGross1").Result = CStr(Val(WCInfo.txtMonthlyGross1) *
12)

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

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