If A Value From An Xml File Is Less Than "x" Then Use Reverse Color. Follow

0
Avatar
Legacy Poster

Hello,   We have a request from a customer that when they print a label format from an xml file that if the Qty value is less than a Total_Qty then print the Qty value in reverse color..

 

For example:

 

Have the following fields on a label defined and the xml file has the following:

 

HR_QTY, 200

HR_TOTAL_QTY, 230

 

Since the HR_QTY is less than the HR_TOTAL_QTY then print the 200 in reverse color.  (Black box around the qty and the qty being white)

 

Is this possible?

9 comments

0
Avatar
Shotaro Ito
Comment actions Permalink

There's no conditional color / font setting change in BarTender (as of 2016R2) - you need VB Script in BarTender document's document options.

Ex. From File > BarTender document options > VB Scripting > OnNewRecord

ReferenceField("HR_QTY")
ReferenceField("HR_TOTAL_QTY")

if CINT(Field("HR_QTY"))<CINT(Field("HR_TOTAL_QTY")) Then
  Format.Objects("TXT_HR_QTY").TextColor = BtColor.White
  Format.Objects("TXT_HR_QTY").TextBackgroundColor = BtColor.Black
Else
  Format.Objects("TXT_HR_QTY").TextColor = BtColor.Black
  Format.Objects("TXT_HR_QTY").TextBackgroundColor = BtColor.White
End if

see the sample attached.

 

0
Avatar
Shotaro Ito
Comment actions Permalink

* Above(document option VB Script) requires BarTender Automation edition or above.

0
Avatar
Ian Cummings
Moderator
Comment actions Permalink

Or you can have two objects or layers giving the two print options, and then set the condition for when the object/layer is to print based on the value of the data source.

0
Avatar
Legacy Poster
Comment actions Permalink

Your example appears to be pulling from two database fields in your CVS file.  Is it possible to only reference the xml qty fields to get the reverse color??

0
Avatar
Denis
Comment actions Permalink

Hi,
Is it possible to reverse color with barteder 9.01 or 10.1 with vbscript OnProcessData?
I need reverse depends on value of database field

I try:


if CInt(Field("Reverse SN")) = 1 Then
Format.Objects("TextSN").TextColor = BtColor.White
Format.Objects("TextSN").TextBackgroundColor = BtColor.Black
End if

But OK button shows Warning message #5901
"This script didnt read from the "Value" property, which means that the currently specified data source was completely ignored. This may not be what you intended"

And on Lookup I get error with need object BtColor

0
Avatar
Shotaro Ito
Comment actions Permalink

BarTender 9.01 didn't have color control.

In BarTender 10.1 Automation Edition, you can modify object color by Document Option VB Script (not OnProcessData)

 From File > BarTender document options > VB Scripting

As example above.

 

0
Avatar
Denis
Comment actions Permalink

Thanks a lot!

And how change color per Data Source. My Text Object consists of 3 Data Sources. In one of them I need to change color.

0
Avatar
Shotaro Ito
Comment actions Permalink

Unfortunately change color/font per data source is not supported.

You can try HTML text object, however in 10.1 text print quality is not very good. (HTML text print quality improved in BarTender 2016 R3)

0
Avatar
Denis
Comment actions Permalink

Thanks for the information.

Please sign in to leave a comment.