Print Or Suppress Image Conditionally
Hello. I need to print an image conditionally on a label. The condition is that fieldA (where fieldA is a database field) has a value, i print the image. If fieldA is blank, i do not want to print the image on the label. i have done labels before but am afraid this calls for VB scripting which i don't know how to do. Can anyone offer some assistance?
I was thinking I could even check the value and use a white versus black font color -just an idea...
thanks,
Laura
I was thinking I could even check the value and use a white versus black font color -just an idea...
thanks,
Laura
0
-
In the picture object properties:
1. Under the "Picture" tab select the error handling radio button so that the label always prints.
2. Under the "Data Source" tab choose your database field and then click the "More Options" button. Select the "VB Scripting" tab, tick the "Use VB Scripting" checkbox and then click the "Edit" button to create a VB script for the "OnProcessData" event.
3. You script will be a conditional statement of some kind like the below:
If value = X Then
value = ""
Else
value = value
End If
In the above example if the value of the database field the picture object is connected to is X then it sets its value to nothing which will result in the object not printing. Otherwise we go ahead and set it to the value in the database. In truth we could leave that bit out if you want.0 -
Legacy Poster
★ BarTender Hero ★
Thanks for your reply. I am having trouble getting this to work because I am embedding the picture. It's a special logo that has to print for only certain parts (parts with a value in the fieldA). So I have to check fieldA value and can use the "If then" statement but i am not getting how to connect the picture to the condition's checked.
Any more advice is greatly appreciated0 -
You won't be able to use an embedded graphic, it will need to be data sourced, linking to a file is best. Specify the path to the folder containing the images under the "Picture" tab, and in the "Data Source" tab select the database field you wish to use. If you wish, set the "Sample data" with the name of the picture file you wish to display on the label; for example Template.jpg 0 -
Legacy Poster
★ BarTender Hero ★
Brilliant - thanks !! I linked the image to the file path and put the name of the jpg in the conditional statement on the database field (VB Scripting) and it works beeuatifully!
0 -
Legacy Poster
★ BarTender Hero ★
I have 3 pictures, the object names are:
Afbeelding 1
Afbeedling 2
Afbeedling 3
Now I want to create in VB something that will show Afbeelding 1 when databasefield Assortment is 20, show Afbeelding 2 when databasefield is 30, show Afbeelding 3 when databasefield is 40 else show nothing.
Please advise.
====
I tested with the answer of last topic but when I insert in the more option VB scripting of my databasefield the code
If value = 20 Then value = "Objects.Afbeelding 1" Else value = "" End If
I will get an error of BarTender in the code saying Types are not correct: '[string: "Field: Date"]' in Line 8 however the code does not have 8 lines...0
Iniciar sesión para dejar un comentario.
Comentarios
5 comentarios