Type Mismatch Error 追蹤

0
Avatar
Legacy Poster

I have a function named ConvertModName. This is in the Label Format Options -> VB Scripting -> Functions and Subs

 

Public Function ConvertModName(PreConvName)
 
    Select Case PreConvName
        Case "B"     ConvertModName = CStr("AI2-TC")
        Case "C"     ConvertModName = CStr("AI2-DC") 
        Case Else    ConvertModName = CStr(PreConvName)
    End Select
 
    Exit Function 
End Function
 

Then in the OnAutoSelectedEvent script for a text object I have code:

 

ReferenceField("BARTEND.008") 
Value =  ConvertModName(Field("BARTEND.008"))
 
When the script tries to process I get a type mismatch error. 
 
However, if I was to move the function to Function and Subs event under the text object it works. 
 
Any clues.
 
I thought by putting my function in Label Format -> VB Scripting I would make it global but perhaps that is not the way.
 
Thanks for any help.
 
Will

2 意見

0
Avatar
Legacy Poster
評論操作 永久連結

So, is this possible?

0
Avatar
Fernando Ramos Miracle
版主
評論操作 永久連結

Hello Williamc,

 

The "Functions and Subs" section of the document level VB script (from the "File>BarTender Document Options...") only affects that precise VB Script, it won't be accessible from a data source type VB script or an "OnProcessData" VB script. Note that there are many functions that are only available at the document level (basically anything that modifies an object's properties) and accessing them from other level VB Scripts could potentially cause problems.

 

Also note that if you are referencing a database field on your code, you'll need to add your code in the "OnNewRecord" event. Using the "OnAutoSelectedEvent" will only allow you to preview the result on screen, but won't be useful at print time.

 

Regards.

登入寫評論。