Condition in calculation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vsts2007
    New Member
    • Sep 2007
    • 56

    Condition in calculation

    Hi
    I am preparing a database for salary statements. In this the HRA should calculated depending upon the data provided in another field.

    For ex:
    if i had a field "HRA applicable" the data entered in that particular field should be "yes" or "no". Depending upon the data of that particular field HRA should be calculated.

    Is it possible to create such condition in access.


    please help me
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Originally posted by vsts2007
    Hi
    I am preparing a database for salary statements. In this the HRA should calculated depending upon the data provided in another field.

    For ex:
    if i had a field "HRA applicable" the data entered in that particular field should be "yes" or "no". Depending upon the data of that particular field HRA should be calculated.

    Is it possible to create such condition in access.


    please help me
    Hi

    Well, yes it is !!??


    MTB

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      [CODE=vb]Private Sub HRA_Applicable_ AfterUpdate()
      If Me.HRA_Applicab le = "yes" Then
      Me.CalculatedHR A = 'Do calculations here
      Else
      Me.CalculatedHR A = ""
      End If
      End Sub[/CODE]

      Linq ;0)>

      Comment

      • vsts2007
        New Member
        • Sep 2007
        • 56

        #4
        My database is based on query, so where can i write this code in form or query
        sorry to ask this

        Comment

        • Zwoker
          New Member
          • Jul 2007
          • 66

          #5
          In your query you could add a new field something like this:
          HRA_Calc: IIf([HRA_Applicable]="yes",50*0.1,0 )

          Obviously the 50*0.1 would be whatever you wanted the actual calculation to be. I have assumed you want a zero value when it is not true. If not, replace that final zero with default value you want when it is not true.

          How's that?

          Comment

          • vsts2007
            New Member
            • Sep 2007
            • 56

            #6
            I tried this, but when i try to open the form to enter data it is asking the question "HR applicable" in the beginning itself. but i want it when i enter data in that particular record.

            Comment

            • Zwoker
              New Member
              • Jul 2007
              • 66

              #7
              Okay... I'm confused. You say you want the calculation in a query, but you mention a form in your last post.

              Can you describe what you are doing? How does your query and form relate to each other?

              If you meant that when you run the query that it is prompting you for a value of "HRA_Applicable " (or equivalent) then it would imply you don't have a field of that name, or you have a field with spaces in it's name that you need to put the square brackets around when you reference it, etc...

              Comment

              • vsts2007
                New Member
                • Sep 2007
                • 56

                #8
                Its query only, For convenience in data entry i prepared form from that.

                Comment

                • vsts2007
                  New Member
                  • Sep 2007
                  • 56

                  #9
                  Can anybody guide me in this issue please

                  Comment

                  • MikeTheBike
                    Recognized Expert Contributor
                    • Jun 2007
                    • 640

                    #10
                    Originally posted by Zwoker
                    If you meant that when you run the query that it is prompting you for a value of "HRA_Applicable " (or equivalent) then it would imply you don't have a field of that name, or you have a field with spaces in it's name that you need to put the square brackets around when you reference it, etc...
                    Have you examined/answered/resolved the above issue ?

                    MTB

                    Comment

                    • vsts2007
                      New Member
                      • Sep 2007
                      • 56

                      #11
                      Hi,

                      Its working actually but i am not able to enter the option "yes" in query i am able to enter the option in table not in query. But the calculations are correct.

                      can you suggest any solution for this

                      Comment

                      • vsts2007
                        New Member
                        • Sep 2007
                        • 56

                        #12
                        Thank You Very Much... Its Working

                        Comment

                        Working...