Conditionally Print A Certain # Of Labels Follow

Legacy Poster



I currently have a label format that pulls information from an access database, on the 'copies per serial number' field I have had it set to a field within the database that calculates the number of labels needed for each product on an order. This works perfectly fine.


What I would like to do is add a checkbox on the data entry form and a number input box, if the checkbox is checked then I want to print the number of labels in the number input box. If the checkbox is not checked then I want to use my database field.


Here is what I have done in the format so far:


Added the checkbox and number input box to the data entry form, and connected them to "Embedded Data" named data sources. On the checkbox I have set the Checked Value to be "Y" and the Unchecked Value to be "N".


Named Data Source names:




I have changed the Data Source for Copies per Serial Number to be a Visual Basic Script, script type Event Control Scripts.


Here is where I am getting lost, which event should I be making this determination in? OnPrintStart or OnPostPrompt?


What should the script look like (I am new to VBScripting)?


I assume it would be something like:


IF Format.NamedSubStrings("CheckboxData").Value = "N" THEN
Field("Labels") ELSEIF
Format.NamedSubStrings("CheckboxData").Value = "Y" THEN
Thank you for any help,
Jonathan K.
BarTender Enterprise Automation Edition 10.1 SR4 Build 2961


Legacy Poster
Comment actions Permalink

Seems like you're pretty close to the solution you're looking for. I'm not sure it'll work, but it's worth a shot.

I suggest you put the final script in the "OnPostPrompt" event as the script requires data that's only available after the data entry / prompt dialog has been filled.


What your script is missing is assignment to the "Value" variable. Otherwise, the script / BarTender won't know what to do with your "Then"-statements.


If Format.NamedSubStrings("CheckboxData").Value = "N" Then
    Value = Field("Labels")
ElseIf Format.NamedSubStrings("CheckboxData").Value = "Y" Then
    Value = Format.NamedSubStrings("NumberData").Value
End If

Please sign in to leave a comment.