Need To Be Able To Print Out The Last Carton Qty, Which May Be An Odd Lot 追蹤

0
Avatar
Legacy Poster

I have a formula that calculates the total number of cartons based on the total quantity divided by the quantity per carton. This is great if the quantity per carton is the same, but in many cases, the last carton may be less than the rest of the cartons. I know what the qty of the last carton is, but how do I output the last label with this qty?

13 意見

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

I "butchered" an old label I had that used VB to calculate this and i have attached the trimmed down copy which you may be able to use to help you with this.

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

Pete,

 

That is exactly what I was looking for, Thank you!

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

I cannot open the file, it's created on a newer version of the software.  Can you extract out the VB code and post it here?

Thanks,

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

Reposted the file as a v9 label

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

Pete,

Thanks for the template.  It works great if the total items / qty per container is a whole number or a decimal > .5 (rounds up).  If this number is a decimal < .5 (rounds down) then the last label will have the qty per plus the remainder.

Ex: I used 110 total items and 12 per box.  The actual number of labels with two decimal places is 9.17.  Since this rounds down we get 9 labels.  The last label then has a qty per of 14. 

We really need 10 labels with a qty per of 2 for the final label.

I have fiddled with your code but I am not quite up to speed with the Bartender structure yet and I have been getting odd results.  Any help with this would be much appreciated.

 

Thanks,

EdK

0
Avatar
Seb Atkins
評論操作 永久連結

Hi

I have also used this template to try and accomplish this it works great!

the only issue i am having is that i have two quantity fields coming in from my database and depending on whether the one called "quantity" is populated depends on which field gets used. I have mapped these to two named data sources (qtyrcv and quantity).

I have changed the totalqty field into a Visual Basic Script (Multi Line Script) and entered the below VB

If (Format.NamedSubStrings("quantity").Value="") Then
Value=Format.NamedSubStrings("qtyrcv").Value
Else
Value=Format.NamedSubStrings("quantity").Value
End IF

The issue i am now having is i am getting an error when trying to print now

I have checked the rest of the scripts and i cant see any issues,

Anyone have any ideas?

 

Thanks in advance!

 

0
Avatar
Hayden Edwards
評論操作 永久連結

I can't get this file :(

0
Avatar
Seb Atkins
評論操作 永久連結

0
Avatar
Daniel Hsiao
評論操作 永久連結

The legacy forum was 404, may somebody post the template file again please.

0
Avatar
Pete Thane
評論操作 永久連結

I think the original reply was from me and based on this test label:

I am not able to attach it to this post though.

The highlighted field is a VB Script>Event Controlled > OnSerialise field with the following code:

 

Value = Format.NamedSubStrings("percartonfull").Value

Value1 = Format.NamedSubStrings("nooflbls").Value - 1
Value2 = Value1*Format.NamedSubStrings("percartonfull").Value
Value1 = Format.NamedSubStrings("totalqty").Value-Value2


If Format.NamedSubStrings("lblcount").Value = 1 then
Value = Format.NamedSubStrings("percartonfull").Value
Elseif Format.NamedSubStrings("lblcount").Value<Format.NamedSubStrings("nooflbls").Value then
value = value
Else Value = Value1
end if

Value = Value

  

This references a number of Named Data Sources where

lblcount is a sequential number field (starts at 1 and resets to 1 each time the job prints)

totalqty and percartonfull are just test fields (or could be linked to a value from a database)

nooflbls is also a VB Script>Event Controlled field but this time OnNewRecord and includes this code:

Value = round((Format.NamedSubStrings("totalqty").Value/Format.NamedSubStrings("percartonfull").Value),0)

(this also includes RangeChecking Minimum Value 0)

 

 

0
Avatar
Daniel Hsiao
評論操作 永久連結

Dear Mr. Thane,

Still not work, and in the part of "VB Script>Event Controlled > OnSerialise", bartender displayed the warning message " OnSerialize (Line 2): Type mismatch: '[string: ""]' ".

It's had same result both on bartender 2016 R9 and 2021 R3.

below link is the test file which I created (2 diffrent bartender version but same content), may you take a look and give me a favour, please.

https://1drv.ms/u/s!An7XQ0C7_aF4nP5393uAMk58ys74rw?e=DbTE4H

0
Avatar
Pete Thane
評論操作 永久連結

The code in my label works correctly so it look like you must have edited it incorrectly. 

For example for the 1st line type the Value = and then scroll down to the Named Data Sources in the column on the right to add in the link to the correct field and this will add in the Format.Named........ information 

 

0
Avatar
Daniel Hsiao
評論操作 永久連結

I make a mistake, VBScript [OnSerialise] should be the data source of the highlighted field, but I write it in "nooflbls".

It's works now, Thank you, Mr. Thane.

And below is my [OnSerialise] code, rewrite it to correct a bug, on first label, If percartonfull > total qty, will use totalqty as print out qty, not percartonfull.

print out qty > VB Script > Event Controlled > OnSerialise

Value1 = Format.NamedSubStrings("percartonfull").Value
Value2 = Format.NamedSubStrings("totalqty").Value Mod Format.NamedSubStrings("percartonfull").Value

If Format.NamedSubStrings("lblcount").Value = 1 Then
Value = Value1
If Format.NamedSubStrings("totalqty").Value <= Format.NamedSubStrings("percartonfull").Value Then
Value = Format.NamedSubStrings("totalqty").Value
End If
ElseIf Format.NamedSubStrings("lblcount").Value < Format.NamedSubStrings("nooflbls").Value Then
Value = Value1
Else Value = Value2
End If

登入寫評論。