Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Type Mismatch with lookup table in Word 97 1

Status
Not open for further replies.

Anthony904

IS-IT--Management
Jul 15, 2004
153
US
I have a word document with some form fields..

I have a function that acts as a lookup table for several form fields..

Function Testing(iLevel As Integer) As Integer
Select Case iLevel
Case 0
Testing = 5
Case 1
Testing = 5.16
Case 2
Testing = 5.32
Case 3
Testing = 5.48
Case 4
Testing = 5.64
Case 5
Testing = 5.8
Case 6
Testing = 5.98
Case 7
Testing = 6.16
Case 8
Testing = 6.34
Case 9
Testing = 6.52
Case 10
Testing = 6.7
Case Else ' Other values.
Testing = 0
End Select
End Function

-----------

and I'm retrieving like so..

Function Retrieve()

ActiveDocument.FormFields("Text1").Result = Testing(ActiveDocument.FormFields("Text2").Result)

End Function

.............

When I test the code I'm getting a data type mismatch run-time error 13...

The bold is where the error points to..

Does anyone see why I'm getting this error? and how to fix it..

Thanks!
 
You may try this:
ActiveDocument.FormFields("Text1").Result = Testing(Val(ActiveDocument.FormFields("Text2").Result))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks its working now..

Could you tell me what "Val" means?

thanks..!
 
With the cursor inside the word Val press the F1 key.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Yes... seems like I missing some help files on my word.. the help function doesnt work..

Also, I was looking at the wrong field..

I'm not getting the error anymore.. but data is not being returned to my field..

it's returning a blank..

 
oops nvm..

but my help function isn't working in word.. =/

if you could .. copy and paste it here..

THanks!
 
For debugging purpose you may play with something like this:
MsgBox "'" & ActiveDocument.FormFields("Text2").Result & "'"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks!.. I looked up the Val function..

Converting strings into number..

Great! learned something new =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top