Type Mismatch Error Follow


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:


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.


Legacy Poster
Comment actions Permalink

So, is this possible?

Fernando Ramos Miracle
Comment actions Permalink

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.



Please sign in to leave a comment.