Skip to main content

Search

Search

Conditional Value Increase With Sql?

Comments

4 comments

  • Avatar
    Domingo Rodriguez
    Moderator

    You should be applying this instead by using VBScript over the text object's data source which will display the price on your BarTender document, something like:

     

    If Field("StockItem.TaxCodeID") = "2583" Then

      value = value * 1.20

    End If

    0
  • Avatar
    Legacy Poster

    Hi! Thank you for stepping me in the right direction with the VB - I've applied the code to the Price field, however I get the message:

     

    "This script did not read from the 'Value' property, which means that the currently specified data source was completely ignored", and no calculations are done.

     

    However if I just use Value = Value * 1.20 (as a test) the priced changes accordingly.

     

    Any ideas?

    0
  • Avatar
    Legacy Poster
    got it! I just had to change the parenthesis:


    If Field ("StockItem.TaxCodeID" = "2583") Then

    value = value * 1.20
    End If


    This got it working, and now tax is applied =D Thanks Domingo!


    ---ADDITION:---
    Is there any way for this VB to be applied to a currency field?
    0
  • Avatar
    Domingo Rodriguez
    Moderator

    When you choose "Currency" as the data type, you could still set the Source under the "Data Source" tab to be "VBScript", for example an "Event Control Script" one. The data types might be conflicting though (String vs numeric operations) so you might first need to do some data type conversions.

     

    What you could do is to use the FormatCurrency() VBScript function instead and then convert your numeric value to a currency:

     

     

    FormatCurrency Function

     

    Returns an expression formatted as a currency value using the currency symbol
    defined in the system control panel.

     

    FormatCurrency(Expression[,NumDigitsAfterDecimal
    [,IncludeLeadingDigit [,UseParensForNegativeNumbers
    [,GroupDigits]]]])

     

    Arguments

     

    Expression

     

    Required. Expression to be formatted.

     

    NumDigitsAfterDecimal

     

    Optional. Numeric value indicating how many places to the right
    of the decimal are displayed. Default value is -1, which indicates that the
    computer's regional settings are used.

     

    IncludeLeadingDigit

     

    Optional. Tristate constant that indicates whether or not a
    leading zero is displayed for fractional values. See Settings section for
    values.

     

    UseParensForNegativeNumbers

     

    Optional. Tristate constant that indicates whether or not to
    place negative values within parentheses. See Settings section for values.

     

    GroupDigits

     

    Optional. Tristate constant that indicates whether or not
    numbers are grouped using the group delimiter specified in the computer's
    regional settings. See Settings section for values.

     

    Settings

     

    The IncludeLeadingDigit, UseParensForNegativeNumbers, and GroupDigits
    arguments have the following settings:

     

    Constant Value Description TristateTrue -1 True TristateFalse 0 False TristateUseDefault -2 Use the setting from the computer's regional
    settings.

     

    Remarks

     

    When one or more optional arguments are omitted, values for omitted arguments
    are provided by the computer's regional settings. The position of the currency
    symbol relative to the currency value is determined by the system's regional
    settings.

     

    Note   All settings information comes from the
    Regional Settings Currency tab, except leading zero, which comes from the Number
    tab.

     

    The following example uses the FormatCurrency function to format the
    expression as a currency and assign it to MyCurrency:

    Dim MyCurrency
    MyCurrency = FormatCurrency(1000)   ' MyCurrency contains $1000.00.
    0

Please sign in to leave a comment.