Help about calculate using data base field + data form
Hi everyone, see, if anyone can me help with it.
I need know if the BarTender is capable to do.
We have the following scenario:
I have a label that need calculate a discount price on the time of printing.
I created a label linked with database (excel), that get the value of product them, the next step,
create a dataform where the user type the value of discount in the field.
Need that Bartender get the value in the database and apply the value percent that was typed in the form and automaticaly calculate the final result and print it.
Example: Database field = 100.00
Field dataform typed = 10%
Print result = 90.00
Attached image ilustred the scenario. Thank you !!
-
pthane
★ BarTender Hero ★
You will need to use a Visual Basic Script routine to achieve this.
- As the discount amount is not shown on your label, add a field to the side of the label (so it wont actually be printed but can be referenced) and using the Change Data Source Name button, give this field a name, I just called mine "Discount" for the code below
- On your Data Entry Form, link the user entry field to the "Discount" field
- For your amount field, change the Type to Visual Basic Script and choose the Event Controlled Script option and then press the Edit with.... button (you may also want to set the Data Type to number so that the final field goes to two decimal places). See the image below for the VB settings and I have also ringed the Change Data Source Name button mentioned in 1. above
1 -
pthane
★ BarTender Hero ★
Seemed to have submitted that without finishing it
- In the central edit box with the OnAutoselectedEvent highlighted, change the entry to Value = 100 (to give the field a default value to stop an error being displayed)
- Next scroll down the left hand column and highlight OnIdenticalCopies and in the central box add the following
Value = Format.NamedSubStrings("FullPrice").Value SEE NOTE BELOW
Value1 = 100- Format.NamedSubStrings("Discount").Value
Value = (Value * Value1)/100
NOTE: for the top line, type Value = and then in the column on the right select/double click on the database field where the full price amount is retained. This will change your line to something like Value = Field(<Database name\/table\field name>). value. My label was not linked to a database but just a named text field on my test label. Repeat this action on the second line but instead choose the name of the field you entered in 1 above from the Named Data Sources options in the right hand column.
- close to come out of the VB screen and that should be it
1 -
Altivo Almeida
★ BarTender Hero ★
Hi Pete, Thank you, work fine !!
0 -
Kiran Babu
★ BarTender Hero ★
Hi Peter. With Bartender 2019/2021 do we have any easier option to achieve this? If VB script is the only solution, can you suggest any source to learn more on the VB scripting for Bartender so that I can leverage Bartender to the most.
0 -
pthane
★ BarTender Hero ★
No I do not think anything has changed to amend this. BarTender is a label printing program and not designed in it's basic form to carry out maths functions. It does do some automatically as part of the process, such as calculating check digits of barcodes but for anything else then you either need to perform these functions outside of BarTender and then tell it what to print or else use the inbuilt VB script to achieve this.
Sorry I am not sure, all my stuff is self taught from either messing around with it or from googling solutions on line and modifying and implementing these to suit. I expect there maybe courses etc you can go on to learn how to program VB/VB script if you want to go that far.
1
請登入寫評論。
評論
5 條評論