Skip to main content

Search

Search

Type Mismatch Errors

Comments

6 comments

  • Avatar
    Ian Cummings
    Moderator

    Could it be that the ScaleWeight data source is already a double value and therefore cannot be converted to a double?

     

    For debugging purposes insert the below expression using the TypeName() function to find out what type this data source already is.

     

    MsgBox("ScaleWeight = " & TypeName(Format.NamedSubStrings("ScaleWeight").Value))

    0
  • Avatar
    Legacy Poster

    Running the MsgBx code I get:

     

    ScaleWeight = String.

    0
  • Avatar
    Ian Cummings
    Moderator

    Can you attach a simplified BarTender document file that demonstrates the issue for us to look at?

    0
  • Avatar
    Legacy Poster

    I've found the problem.  The file that comes from the scale has some leading and trailing non-numeric characters in it.  I missed this because when that data is used directly in a field on the Bartender label, it prints only the numeric data.  When I try to use it in a vb calculation however, it errors out.  If I edit the file to remove these characters, the calculation works and the label prints with correct data.

     

    In the first Bartender field, I have the Data Source set as the Database Field that is the text file from the scale.  In the fields properties I have the Data Source named as "ScaleWeight".  I also have the Data Type set to Number.

     

    In the second Bartender field I am using vbscript as the Data Source as shown in my first post above.  If I now edit that script as follows, it works and prints correctly, but there is an additional problem.

     

    Dim Price, Weight

    Price = Format.NamedSubStrings("UnitPrice").Value

    Weight = CDbl(Left(Right(Field("ScaleData.Field 1"),11),9)

    Value = Round(Price * Weight,2)

     

    The additional problem is that when I use this code, the First Bartender field that also uses Field("ScaleData.Field 1") as its Data Source does not print and remains blank.  If I use Format.NamedSubStrings("ScaleWeight").Value instead of Field("ScaleData.Field 1") in the code above, it does not work.  It looks like I have to use the Database field directly in the vb script to get it to work.  This implies that the data from the file may only be used once in one field and then it becomes unavailable, but I need to use it twice - once in each of two fields.

     

    I do have Commander set to rename and delete the file after it is read, but I've eliminated this variable by turning Commander detection off, placing an example file in the folder so the label can access it, and trying to just print.  So, it looks like Bartender simply won't access the text file for more than one field's Data Source.  How can I work around this?

     

    I have tried changing the Data Source of the first Bartender field to vbscript with this code:

    Value = ReferenceField("ScaleData.Field 1")

    it then prints as 0.00 rather than simply being blank, but still does not seem to access the real value in the text file.

     

     

    Again, thanks for your help.

    0
  • Avatar
    Legacy Poster

    If I change the Data Source of the First Field and point to the text file as an External File (settings below), then everything works.  However, Commander evidently requires that the trigger text file be treated as a Database Field rather than as an External file.  Commander is not allowing the file to print and is getting hung on the print command for some reason. But if I change the First Bartender field's Data Source back to the Database source which is Field("ScaleData.Field 1"), then the VB script in the Second Bartender field fails again on a type mismatch error. 

     

    This works with an External File, but Fails with the same text file used as a Database Source from Commander:

     

    First Bartender field I settings:

    Data Source Name: ScaleWeight

    Data Source Type: External File

    Data Type Type: Text

    Transforms Character Filter: Custom (allow characters 1234567890.)  Set warning to Off.

    Transforms Suffix: lbs.

     

    Second Bartender field I settings:

    Data Source Type: VB Script

     

    Dim Price, Weight

    Price = Format.NamedSubStrings("UnitPrice").Value

    Weight = CDbl(Left(Format.NamedSubStrings("ScaleWeight").Value,5))

    Value = Round(Price * Weight,2)

    0
  • Avatar
    Domingo Rodriguez
    Moderator

    As mentioned before, can you attach a simplified BarTender document file that demonstrates the issue for us to look at? Attach the trigger data file as well please.

     

    Is the problem reproducible by just connecting the BarTender document to the text file (so without using Commander)?

     

    Also, what exact Edition, version and build of BarTender is in use?

    0

Please sign in to leave a comment.