How To Change A Qty Field On The First Or Last Label
I created two named data sources. one for the page number (PageNum) and one for the Total Number of Pages (TotalNumberOfPages). Both fields display correctly the current and total page numbers.
I would like to "Look" at the current page number and compare that with the total pages so I can modify my quantity field for the last label.
I have product that fits 100 per box. If I am shipping 350 parts - then I will need 4 labels. i.e. 3 boxes of 100 and 1 box of 50.
I was able to add a script to the Quantities in BarTender to calculate the number of labels.
However I don't seem to be able to detect the last page. When I try to reference the page number my logic does not work.
I created the page number field with:
Dim LabelPageNum
LabelPageNum = Format.NamedSubstrings("PageNum").Value
Value = LabelPageNum
The formula I am using on the label is:
IF Format.NamedSubstrings("PageNum").Value = "4" Then
Value = "Hello"
Else
Value = "Not There"
End If
This formula always returns "Not There" no matter what page is being printed.
I have tried a number of String tests. i.e I see that the string has a length of 3. So I tried adding &CrLF to the test string however that did not work.
If there is anyone out there that has done this I would be gratefull for any advice.
Thank you,
Dave Olender
Ph: 651-246-3281
-
Legacy Poster
★ BarTender Hero ★
I changed the formula to use Format.Objects("PageNum").Value and now the If..Then..Else works.
0 -
Legacy Poster
★ BarTender Hero ★
Sorry I was too quick. It appears that the logic only works on the first record. So testing for Page 1 works. However testing for the last page does not.
When I look at the ASC string for all pages other than one I am getting 636363. I really only need to look for the first or last page so I can make this work.
But I would rather understand why this is happening and what if I wanted to test for the last page? How could I do that.
Sorry this one is not solved quite yet.
DaveO
0 -
Unfortunately you don't mention the edition and version of BarTender that you are running, but have you tried using the "Page Number" option of the "Print Job Field" data source type to get the current page number?
I trust you're using an event based VB script for your code, using either the "OnIndenticalCopies" or "OnSerialize" events which thus allows you to check the page number for the current page in the on going print job that's being rendered?
0 -
Legacy Poster
★ BarTender Hero ★
The version I am running is 2016. I am still unable to detect the last label.
This is frustrating me to no end. I can put a text field on the label and I can correctly display the Current Page Number AND the Total Number of Pages.
However, if I try to reference that field or dataset value in a formula i.e. If ... Then ... Else I am unable to get detect the last label.
Here is my simple condition:
If Format.NamedSubStrings("PageNum").Value = Format.NamedSubStrings("TotalPagesCount").Value Then
BoxQty = "5"
End If
Value = BoxQty
I have this code inserted into an Event ControlScript of OnSerialize (however I have tried others as well).
The PageNum and TotalPagesCount are datasources I created and when I associate them with text boxes the correct data is displayed.
Thanks for any help.
I can't be the only one to come across this - I must be doing something stupid.
DaveO
0 -
Hmmm, I'm having problems trying to get this to work also. I've logged a request with development for assistance.
0
請登入寫評論。
評論
5 條評論