Alpha Video Training
Results 1 to 5 of 5

Thread: Setting Field Value

  1. #1
    Member
    Real Name
    Melvin
    Join Date
    Nov 2011
    Posts
    133

    Default Setting Field Value

    Hi All

    I've got a tricky coding question.

    My desktop application is built for users to enter parts orders from customers. In the order table there is a shipping insurance field called "ins_cost" and a total parts cost field called "part_cost". I want the value for the shipping insurance field to self populate based on the value in the total parts cost field. Below is the list of my insurance cut off points.

    Part Cost Value Insurance Cost Value
    $0.00 - 149.99 $0.00
    $150.00 - 199.99 $3.34
    $200.00 - 299.99 $4.00
    $300.00 - 399.99 $5.34
    $400.00 - 499.99 $6.68
    $500.00 - 599.99 $8.00

    What is the best way to code this from the calculated field rules?

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Setting Field Value

    You could code it as a lookup() to an insurance cost table or use a case() statement.

    Code:
    cost = 229.99
    
    
    ? case(cost<= 149.99,0,cost<=199.99,3.34,cost<=299.99,4,cost <=399.99,5.34,cost<=499.99,6.68,cost<=599.99,8)
    = 4

  3. #3
    Member
    Real Name
    Melvin
    Join Date
    Nov 2011
    Posts
    133

    Default Re: Setting Field Value

    Thanks Stan!! The case() statement works nicely for me.

  4. #4
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Setting Field Value

    The lookup() would have the flexibility of allowing you to change the rates without having to edit the field rule. Your choice.

    In either case, rather than making this the calculation for a field you should probably make it the simple default expression for a data entry field rule. In that way the derived value will remain in the field even if an adjustment is made to the insurance costs. The value in already created records will not be changed by a recalculation of all rules.

  5. #5
    Member
    Real Name
    Melvin
    Join Date
    Nov 2011
    Posts
    133

    Default Re: Setting Field Value

    Quote Originally Posted by Stan Mathews View Post
    The lookup() would have the flexibility of allowing you to change the rates without having to edit the field rule. Your choice.

    In either case, rather than making this the calculation for a field you should probably make it the simple default expression for a data entry field rule. In that way the derived value will remain in the field even if an adjustment is made to the insurance costs. The value in already created records will not be changed by a recalculation of all rules.
    Thanks for the reminder...I've set it as a on change event.

Similar Threads

  1. In a form or at a field setting
    By Penny in forum Alpha Five Version 9 - Desktop Applications
    Replies: 11
    Last Post: 01-12-2009, 04:07 PM
  2. Setting Field values
    By DRW in forum Alpha Five Version 8
    Replies: 10
    Last Post: 06-12-2007, 05:32 PM
  3. Setting Field Via Form
    By mazatec in forum Alpha Five Version 7
    Replies: 6
    Last Post: 02-08-2007, 01:19 AM
  4. Setting a field from calculated field
    By Zod Mansour in forum Alpha Five Version 6
    Replies: 4
    Last Post: 09-19-2004, 04:14 PM
  5. Setting a Field
    By Alan Anthony in forum Alpha Five Version 5
    Replies: 3
    Last Post: 01-28-2003, 06:43 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •