Using Multiple Data Sources to the same text box.
I want to create a text box regarding the allergen information that will be like "May contain Gluten, Egg and Milk". The information whether the product contains the allergen or not will feed from an access database similar to below.
For example, for product 1001 it should state "May contain Egg and Nut", for product 1002 "May contain Milk and Nut" etc.
Is this possible to do with Bartender 2021?
-
pthane
★ BarTender Hero ★
Yes that is possible.
You could set it up something like this (I have used a simple text file with just some of the data for this)
The top string is an Embedded text with the words "May Contain: " and I have also, in case all the answers are "no", set the Transforms>Suppression for this to
The second substring is a VB Event Control Script>OnNewRecord and includes the following code:
Value1 = Field("maycontaindemo.maycontaindemo.gluten")
if Value1 = "may contain" then
Value1 = "Gluten,"else Value1 = ""
end if
Value2 = Field("maycontaindemo.maycontaindemo.egg")
if Value2 = "may contain" then
Value2 = "egg,"else Value2 = ""
end if
Value3 = Field("maycontaindemo.maycontaindemo.milk")
if Value3 = "may contain" then
Value3 = "milk,"else Value3 = ""
end if
Value = Value1 & Value2 & Value3For the ValueX = lines, type in the ValueX = and then double click on the Database field name you want to use from the Script Assistant box on the right to create the correct link.
The date I used was
code,gluten,egg,milk
1001,yes,may contain,may contain
1002,yes,yes,may contain
1003,may contain,yes,yes
1004,no,no,noand this is the result
0 -
Georgios Gounaropoulos
★ BarTender Hero ★
Hi Peter,
I have tried to follow all the steps but it comes with the below error when trying to print preview the label:
If i click continue on the error bar it will just show May contain: <Blank>.
Can you please advice on the above? Thank you.
0 -
pthane
★ BarTender Hero ★
Not sure. You did add the database link in via the Script Assistant field I take it?
Can you add the Gluten on as a text field linked to your database and does that work? If so add it onto the label and then drag it off to one side off the printed area, as you do not need it to print, but give the text object a name and then in the VB field the Script Assistant should then include a Named Data Sources and so you could use that rather than the Database link
0 -
Georgios Gounaropoulos
★ BarTender Hero ★
Hi Peter,
I have created a text box for gluten, egg, milk and linked to the database and it worked :) Thank you for your help.
One more question, do you know if we can set the vb script to put "and" between the last two allergens?
So, the final output to be "May contain eggs, milk, and nuts" or "May contain eggs, milk and nuts" or for only one allergen "May contain nuts".
Thank you.
0 -
pthane
★ BarTender Hero ★
A bit of work required to acheive this:
I would suggest amending the VB to only reference one Allergen at a time and include an Event Controlled Script for each of these instead and also Name these fields as VBGluten, VBEgg etc. Then add ", " and an " and " strings as shown below
The VB for each string should look something like this
Value = Field("MayContainTest.MayContainTest.gluten")
if Value = "May Contain" thenValue = "Gluten"
else Value = ""
end if
Note: make sure to delete the comma from the Value = "Gluten" string that I had included previously.
For the first two " and " strings on the Transforms tab set the Suppression to
whilst for the final " and " makes this the Next Data Source not Previous.
The first ", " needs the Suppression set to
whilst the second one
0 -
Georgios Gounaropoulos
★ BarTender Hero ★
Thank you for your help Peter :)
0
Please sign in to leave a comment.
Comments
6 comments