If statement help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lghovden06
    New Member
    • Jul 2008
    • 6

    #1

    If statement help

    I am doing a monthly report for a company in access. I am fairly new to access so I don't know a whole lot. The report was orginaly created in excel. one of the columns, accounts receivable, equals the previous days accounts receivalbe + time sales - Rec on Account. At the beginning of th month the Accounts Receivable equals the final day in the last month's. I am trying to create an if statement to check if it is null.
    Here is what I kind of came up with
    Accounts_Receiv able: If(IsNull( [Accounts_Receiv able]),[last_month]+[time_sales] - [rec_on_acc], [Accounts_Reciev able] + [time_sales] - [rec_on_acc]

    I don't even think this is close but PLEASE HELP!
  • hjozinovic
    New Member
    • Oct 2007
    • 167

    #2
    Originally posted by lghovden06
    I am doing a monthly report for a company in access. I am fairly new to access so I don't know a whole lot. The report was orginaly created in excel. one of the columns, accounts receivable, equals the previous days accounts receivalbe + time sales - Rec on Account. At the beginning of th month the Accounts Receivable equals the final day in the last month's. I am trying to create an if statement to check if it is null.
    Here is what I kind of came up with
    Accounts_Receiv able: If(IsNull( [Accounts_Receiv able]),[last_month]+[time_sales] - [rec_on_acc], [Accounts_Reciev able] + [time_sales] - [rec_on_acc]

    I don't even think this is close but PLEASE HELP!
    hey Ighovden,

    I believe the best solution would be to have a running sum.
    I'm talking about Reports here. If you're creating a report you can have a running sum field that would always have the latest 'sum'.
    It would not matter wether the sum is from previous month or not.

    You can read more about creating a running sum in reports if you search MsAccess help for 'running sum'.

    regards,
    H.

    Comment

    • salimudheen
      New Member
      • Jan 2007
      • 14

      #3
      Hey,
      I think u create the report using Ms Access. In ms access report field, use the IIF statement instead of if statement u declared. Others in ur statements are correct.

      Comment

      • lghovden06
        New Member
        • Jul 2008
        • 6

        #4
        Originally posted by hjozinovic
        hey Ighovden,

        I believe the best solution would be to have a running sum.
        I'm talking about Reports here. If you're creating a report you can have a running sum field that would always have the latest 'sum'.
        It would not matter wether the sum is from previous month or not.

        You can read more about creating a running sum in reports if you search MsAccess help for 'running sum'.

        regards,
        H.
        Hi,
        Thank you for the reply. My only proublem with a running sum is one of the equations for a field "Accounts_Recei vable" incolvel more than one row. For example here is what it looked like in excel =(Y1 + V2) - W2 next cell down would look like this =(Y2+V3)-W3 Y in the Accounts receivalbe column V is Time_Sales and W is Rec_on_Acc. In Access the Accounts_Receiv able field will start with the end of last months Accounts_Receiv albe, but if I type the equation Accounts_Receiv able: Accounts_Reciev able + Time_Sales - Rec_on_Acc it uses the Accounts_Receiv alble on that row which is zero. it needs to use Accounts_Receiv able in the above row and then use Time_Sales and Rec_on_Acc in the current row.
        I hope this makes some sense. I had a hard time describing it in words. If this doesn't make sense I can try to reword it.
        Thanks

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Originally posted by hjozinovic
          hey Ighovden,

          I believe the best solution would be to have a running sum.
          I'm talking about Reports here. If you're creating a report you can have a running sum field that would always have the latest 'sum'.
          It would not matter wether the sum is from previous month or not.

          You can read more about creating a running sum in reports if you search MsAccess help for 'running sum'.

          regards,
          H.
          The general Logic would be:
          Code:
          IIf(IsNull([Accounts_Receivable]), 0, ([last_month] + [time_sales]) - [rec_on_acc])

          Comment

          • Stewart Ross
            Recognized Expert Moderator Specialist
            • Feb 2008
            • 2545

            #6
            Hi. There are things that spreadsheets are much better at than databases - and one of them is the ability to generate row-by-row running sums. Databases can't easily mimic that kind of functionality, because the relational database model has no concept of record position.

            If you look at how a spreadsheet does it, the running sum is adding the current cell to the previous value for that cell, all down a particular column. In spreadsheets, this relies on every row having a specific row and column position (or address). So, to produce a running total we add a new column and populate it with references to the previous cells (D2 = A2 + A1 for example, where A1 is a reference to the previous row's value). The key concept here is that every row of a spreadsheet has a reference number - which is not the case in a database.

            Without the row referencing of the spreadsheet it is very difficult to describe the logic of the calculation in such a way that it can take place at all. The running sum for reports is a good example of how something like it can be achieved, but not easily within a general query.

            Usually, to do a running sum in SQL involves self-joining a copy of a table to itself using some field (such as a date) to achieve a join of the current records to the previous one. It can be done, but is neither easy nor fast. It cannot be done using a simple lookup or built-in formula.

            I would recommend exporting the data to Excel and using its flexibility to do such running SUMs - just as they were done originally. If you have access to the current total, as in your first posts and in subsequent responses, then you can obtain a total for your report - but it is an intermediate total of some kind rather than a running sum.

            -Stewart

            Comment

            • hjozinovic
              New Member
              • Oct 2007
              • 167

              #7
              hey Ighovden,

              I made a small base trying to get the result you are looking for.
              I hope you will find it usefull.

              H.
              Attached Files

              Comment

              Working...