Help about calculate using data base field + data form Follow

0
Avatar
Altivo Almeida

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 !! 

 

3 comments

0
Avatar
Pete Thane
Comment actions Permalink

You will need to use a Visual Basic Script routine to achieve this.

  1. 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
  2. On your Data Entry Form, link the user entry field to the "Discount" field
  3. 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.   
0
Avatar
Pete Thane
Comment actions Permalink

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 
0
Avatar
Altivo Almeida
Comment actions Permalink

Hi Pete, Thank you, work fine !!

Please sign in to leave a comment.