Weight calculation based on quantity S’abonner

0
Avatar
Tim Plunkett

Hi all,

A client of mine recently had some major changes to their label structure requested by a major supplier and because of certain current restrictions put in place it suddenly became my job to help get this sorted before deadline. They were previously using some ancient label software which didn't quite cut it so i started playing around with Bartender which i found to be very helpful! I have managed to sort the labels but am trying to make printing easier by utilizing vb script to help minimize user input. Here is one of the issues:

We have a static value of "BoxWeight" for each product which is stored in our excel file database for our labels. When printing, the user is prompted for a quantity of boxes which is displayed on the final label. There also needs to be a "NetWeight" displayed on the label which is BoxWeight x QTY. This "NetWeight" needs to be displayed in 2 different formats: One is for the barcode and the other as text on the label. The format for the barcode is strangely xxxxxx but with a decimal point. So for example 54kg equals 054.000 when entered by the user (but is displayed as 054000 in the barcode). Currently i have a form which prompts the user to input the data in this format, whilst also asking for the weight in a different format i.e. 54.0 so that it can be displayed as readable text.

My question is: How can i prompt the user just for the quantity so that the net weight is just calculated via vb script (as BoxWeight x QTY) in 2 different formats to be displayed on the label? 

Any help would be greatly appreciated! Stay safe

4 commentaires

0
Avatar
Pete Thane
Actions pour les commentaires Permalien

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
Actions pour les commentaires Permalien

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
Actions pour les commentaires Permalien

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
Pete Thane
Actions pour les commentaires Permalien

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 

Vous devez vous connecter pour laisser un commentaire.