Skip to main content

Search

Search

Weight calculation based on quantity

Comments

4 comments

  • Avatar
    Peter Thane

    I am guessing what you are wanting is something like this, where the 51.2 comes from a database and the 4 is the quantity coming from a different source (Box Quantity entered by the users?)

    For the VB as the weight comes from the database this can be referenced already in a script routine but as the quantity comes for a different source then you will need to give this a Name using the button below so you can call the value at print time. Assuming this is entered by the operators on a Data Entry Form, when you go to create the link for the Form entry box that you select the Name you gave this field on the label. If this quantity isn't printed on the label, add the field on to your template, give it the Name but make sure it is dragged off to the side of the template.  

    As you can see in my example I called it TheQTY.

     

     

     

    For the text weight I have added an VB Script - Event Controlled Script and set to OnIdenticalCopies. I am not sure how you want the text field displayed but for my example I have set the Data Type to number and 2 decimal places and then via the Transforms tab added a Kg suffix.

    Once you have set the correct VB Script Type, click the Edit with Script Editor button to add in the code.

    For the OnAutoselectedEvent you could leave the default value as it is but I changed mine so Value = 1.

    Scroll down the column in the left and select OnIdenticalCopies

    In the Script box in the middle type

    Value = 

    and now in the column on the right double click on weight field in the Database Fields and then press enter to start a new line of code starting

    Value = Value *  

    and then again in the right hand column click on the name given to your quantity input from Named Data Sources

    This completes your code which  should look like this (note there is only one field in my dummy database, all the ones in your database will appear in the list on the right.

     

    For ease you may want to select the two lines of your code and copy it as you will be using this again for the barcode.

    Click Close and Close to return to your Template view.

    Now for the barcode in the Transfroms menu set the Number of Characters Minimum to 6 padding with a Zero but turn off the warning and once you have done this configure the VB Script for the this field exactly the same as the text field but than add one further line at the bottom:

    Value = Value * 1000

    and so the full code should be

    Value = Field("vbweightdemo.vbweightdemo.Weight")

    Value = Value * Format.NamedSubStrings("TheQTY").Value

    Value = Value * 1000

    Again click Close and Close and then you are done.

    I hope this helps

    Pete 

     

    0
  • Avatar
    Tim Plunkett

    OMG Pete thank you very much! That looks to be exactly what i am trying to do. I will try implement this today and will let you know the result. Apologies for the late reply! 

    0
  • Avatar
    Tim Plunkett

    The only thing i had to change was increasing the number min characters to 7 in the barcode wieght field and it worked perfectly! Well, i also removed this OnProcessData transform that I think had been created from the Barcode GS1 field wizard:

    Value = ConvertToEANUCCSevenDigitMeasurement(Value, 3)

    You are a star! Now just onto converting date into different formats but that is for another day.

    Thanks again mate

    0
  • Avatar
    Peter Thane

    If you are using a GS1 code then the weight (310X) should only have a maximum of 6 characters for the weight and the X would be the number of spaces after the decimal point ie (3103)123456 would actually represent 123.456 units of weight 

    0

Please sign in to leave a comment.