Change value of datasource for one label out of a print job
Hello, I am trying to change my Quantity named data source on the last label of my print job I.E the first 7 have a quantity of 6 but the 8th label needs to have a quantity of 5 because it is a partial box. I have been trying to do this with VB, but it only changes the data source after the job has run, changing it on my template. I set the quantity for the first seven in the data form, and then have a second box to change the quantity for a single label, I do have a box to pick which label is being changed and serialization is on.
' Get the label number to change and the new value from the form
Dim labelNumberToChange 'As Variant
Dim newValue 'As Variant
labelNumberToChange = Format.NamedSubStrings("LabelNumberToChange").Value
newValue = Format.NamedSubStrings("PartialQuantity").Value
' Get the serialized label number
Dim serializedLabelNumber 'As Variant
serializedLabelNumber = Format.NamedSubStrings("LabelNumbers").Value
' Compare the serialized label number with the label number to change
If serializedLabelNumber = labelNumberToChange Then
' Try to modify the Text object directly
If Format.NamedSubStrings("Quantity").Value then
Format.NamedSubStrings("Quantity").Value = newValue
Else
MsgBox "'Qty' object does not exist."
End If
End If
this is my current script, maybe someone can help me out!
-
Peter Thane
★ BarTender Hero ★
Looks like you are trying to do something like this,
0 -
Jake Barrett
★ BarTender Hero ★
I went through that post, and I appreciate your response but I don't think its quite what I am trying to do. I don't need a counter going up every label, I need one label to sometimes have a different quantity than the others, taken in with user input. Maybe your post that you linked can be implemented in that way but I have no idea how to do so. I have a data form field for partial quantity and quantity and a field with partial quantity label number, that field is supposed to select which label needs to have the partial quantity number on it instead of the quantity
0 -
Peter Thane
★ BarTender Hero ★
The counter does not need to be displayed on the label but the value is used in the calculation for the part label quantity on the last label whilst also working out the total number of labels to print (full and part).
For yours am I correct in thinking you are entering the full label quantity in one Data Entry Form field and the part label quantity in another? I assume you are also telling BarTender how may labels to print somewhere too, is that correct?
0 -
Jake Barrett
★ BarTender Hero ★
Yes that is correct
0 -
Peter Thane
★ BarTender Hero ★
There maybe different ways to achieve this but this works:
- Create your label as normal but make your box quantity field a Named Data Source (I called mine FullBox) and confirm it is linked to the Data Entry form input for this value.
- Add an additional text field to the side of the template (so it is outside of the printed area) and give this a name (I used NoOfLbls) and link it to a Data Entry Form input box into which the users will type the number of labels required.
- Add another field off to the side of the printed area and name this too, I used CalcQty and make this a VB Script > Event Controlled Script using the OnPostPrompt setting. For now leave this field as it is as we need to add another setting/value first.
- Back to the Template View of you label and click the button to add a new template to the label. On your main template select all the fields on your label and copy and paste these onto your new template.
- For the box contents quantity field on the new template edit the field to Name and rename this field. As you can see I called mine Part Box and then on the Data Entry form link the part box entry field to this string
- Now go back to the CalcQty field and edit the VB script
- You may want to set a default value for this field and you can do this via the OnAutoSelected events and I set mine to
Value = Format.NamedSubStrings("NoOfLbls").Value
adding the Format.Named.... by double clicking on the field from the Named Data Sources list in the Script Assistant box
- This field is used to calculate the number of labels to be printed that have the full box quantity shown and if there is a part box print one less than requested. to do this In the OnPostPrompt area add the following
Value = Format.NamedSubStrings("NoOfLbls").Value
Value1 = Format.NamedSubStrings("PartBox").Value
Value2 = Format.NamedSubStrings("FullBox").Value
If Value1 = Value2 then
Value = Value
elseif Value1 = 0 then
Value = Value
elseif Value1 < Value2 then
Value = Value -1
end if
Value = Value
- Next click on the Page Setup icon and Templates and drag the 2nd template to make it an end of job template.
- This template will not be subject to the usual number of labels setting and we need to configure this to only print when a part box label is required. You can actually see the config on the image above and the Print When box and to set this click on the button to the right of this box.
- Add the two conditions as shown below. For the second one type in [PartBox] into the box and then click on the Text View tab and remove the inverted commas from around this value.
- Finally we need to connect the number of labels to be printed to the CalcQty. To do this, go to File>Print and click on the button to the right of the Copies entry box
- Chose the Set by Data Source option and then use the Name button and select the CalcQty button from the list.
Hopefully that should be it and this is what I get
and with a part box value of not the same as the full box or zero. As you can see I left the two fields mentioned above visible on my template one rather than drag them to the side
0 -
Jake Barrett
★ BarTender Hero ★
Thank you! I will try this and see what I can figure out, I did it a different way for now just have to print it twice since I was on a deadline at work for it, but I appriciate it and will use this to try and implement it down the road! Thanks for your help and responses!!
0
Please sign in to leave a comment.
Comments
6 comments