How to give formula in My issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sandhya1988
    New Member
    • Oct 2014
    • 30

    How to give formula in My issue

    Hello friends, Can anyone help on my issue

    I need some calculation formula about Cust. Disc% and CustDisc Amt fields.

    Both of direct punching fields so in this case i need a formula that is if enter the percentage value in Cust.Disc% field then update automatically CustDisc Amt field. Or enter a value in CustDisc Amt field then update automatically Cust.Disc% field with each MRP and Qty wise as per screenshot values. Both fields are enter the values as choice wise so how to give a formula both fields?
    Attached Files
  • jforbes
    Recognized Expert Top Contributor
    • Aug 2014
    • 1107

    #2
    Add a couple of AfterUpdate Events for CustDisc and CustDiscAmt that update the other related field. You will need to use your actual field names for the example below:
    Code:
    Private Sub CustDisc_AfterUpdate()
        ' Discount Amount = MRP * Discount Percent
        Me.CustDiscAmt.Value = Nz(Me.MRP.Value,0) * Nz(Me.CustDisc, 0)
    End Sub
    Private Sub CustDiscAmt_AfterUpdate()
        ' Discount Percent = Discount Amount / MRP
        If Nz(Me.MRP.Value,0)=0 Then
            Me.CustDisc.Value = 0
        Else
            Me.CustDisc.Value = Nz(Me.CustDiscAmt, 0)/Nz(Me.MRP.Value,0)
        End If
    End Sub
    Additionally, you'll want to trap for a divide by zero error
    Last edited by jforbes; Nov 11 '14, 02:18 PM. Reason: typo

    Comment

    • Sandhya1988
      New Member
      • Oct 2014
      • 30

      #3
      Thank you so much for your replay its working perfectly :)

      Comment

      Working...