Building an expression

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lpape
    New Member
    • Jun 2007
    • 3

    #1

    Building an expression

    I am new to Microsoft Access and I am having to make a change to code that already exists. Here is what I am trying to do:

    B_COST: IIf([DISTR_AMT]NOT NULL,"B_COST",I If([INSUR]NOT NULL,"B_COST"))

    What I am trying to accomplish is the field B_COST will consist of amounts from DISTR_AMT if it is not null or amounts from INSUR if it is not null. I tried using an OR statment but it did not like it.

    thanks
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by lpape
    I am new to Microsoft Access and I am having to make a change to code that already exists. Here is what I am trying to do:

    B_COST: IIf([DISTR_AMT]NOT NULL,"B_COST",I If([INSUR]NOT NULL,"B_COST"))

    What I am trying to accomplish is the field B_COST will consist of amounts from DISTR_AMT if it is not null or amounts from INSUR if it is not null. I tried using an OR statment but it did not like it.

    thanks
    Hi and welcome to TSDN. Hope you have a great time here. I'll have to move your thread to the access forum where the experts there can help.

    Comment

    • lpape
      New Member
      • Jun 2007
      • 3

      #3
      thank you as you can tell I am new to both the scripts and microsoft access. How do I know if somebody has posted to my question

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by lpape
        thank you as you can tell I am new to both the scripts and microsoft access. How do I know if somebody has posted to my question
        You can set email notification in your control panel (link is at the top of the page to the right). You can also check in this thread the same way you saw my response. Anyway they wont take too long to respond otherwise they will be in trouble with me ...


        @Access experts: Now don't be lazy in here. Give some help.

        Comment

        • MMcCarthy
          Recognized Expert MVP
          • Aug 2006
          • 14387

          #5
          @r035198x "Your wish is my command :)"


          B_COST: IIf(NOT IsNull([DISTR_AMT]),[DISTR_AMT],IIf(NOT IsNull([INSUR]),[DISTR_AMT],0))

          This will check DISTR_AMT first and if it is not null will put the value in B_COST. If it is null it will look in INSUR and if that is not null it will put the value in B_COST. If both are null it will put 0.

          Note: If DISTR_AMT is not null it will never check INSUR.

          Comment

          • lpape
            New Member
            • Jun 2007
            • 3

            #6
            Originally posted by mmccarthy
            @r035198x "Your wish is my command :)"


            B_COST: IIf(NOT IsNull([DISTR_AMT]),[DISTR_AMT],IIf(NOT IsNull([INSUR]),[DISTR_AMT],0))

            This will check DISTR_AMT first and if it is not null will put the value in B_COST. If it is null it will look in INSUR and if that is not null it will put the value in B_COST. If both are null it will put 0.

            Note: If DISTR_AMT is not null it will never check INSUR.
            Thanks for the code, but that did not give me both amounts, it only gave me DISTR_AMT. If DISTR_AMT was null it not give me INSUR amount

            Comment

            • MMcCarthy
              Recognized Expert MVP
              • Aug 2006
              • 14387

              #7
              Originally posted by lpape
              Thanks for the code, but that did not give me both amounts, it only gave me DISTR_AMT. If DISTR_AMT was null it not give me INSUR amount
              That's what I said I was giving you. Your original question said you wanted DISTR_AMT or INSUR. Explain the full logic of what you want and I can help you with the code. Give the logic in English, don't worry about the code

              Comment

              Working...