Sub Report Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Zaher Rabah
    New Member
    • Apr 2007
    • 13

    Sub Report Problem

    Hi,

    Explain:

    I have a report for reciept list , it contain 3 sub report.
    1st for cash and it contain sub total 1
    2nd for check and contain sub total 2
    3rd for Credit card and contain sub total 3

    and in the main report i put :
    total = nz(sub total 1)+nz(sub total 2)+nz(sub total 3)

    Problem:

    it give me the right total when the list contain the 3 sub totals.
    But
    the main problem appear when the list have only cash , the sub report of cach appear only , thats logic, but the total in the main report give me "# Error"
    because the 2 other sub report not appear.

    plz can anyone give to me any solution for that.

    Note: Access 2003

    regards

    Zaher Rabah
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    You have posted in the Articles section. I am moving this question to the Access forum.

    ADMIN

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32662

      #3
      I'm not sure I can help you here, but just in case :
      What do you mean when you say that the other sub-reports 'don't appear'?
      Are they invisible perhaps?

      Comment

      • Zaher Rabah
        New Member
        • Apr 2007
        • 13

        #4
        Originally posted by NeoPa
        I'm not sure I can help you here, but just in case :
        What do you mean when you say that the other sub-reports 'don't appear'?
        Are they invisible perhaps?
        yes, they are invisible bc their is no data in them.

        Example:

        This case happen when a client come and pay only cash, so the 2 sub report are empty and invisible.

        Comment

        • dima69
          Recognized Expert New Member
          • Sep 2006
          • 181

          #5
          I am familiar with this problem. My solution is this:
          1. In the main report module write a function
          Code:
          Function GetSubTotal(SubFRM as String) as Currency
          On Error Goto Err1
          GetSubTotal = Me(SubFRM)![sub total]
          exit function
          err1:
          GetSubTotal = 0
          end function
          2. At the main form, put calculated field like this:
          Code:
          =GetSubTotal("SubFRM1")+GetSubTotal("SubFRM2")+GetSubTotal("SubFRM3")

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32662

            #6
            Originally posted by Zaher Rabah
            yes, they are invisible bc their is no data in them.

            Example:

            This case happen when a client come and pay only cash, so the 2 sub report are empty and invisible.
            I'm really trying to ask 'how' they are invisible here. On which objects (if any) do you set the visible property to False?
            If an object (control) were simply devoid of data I can't see why the Nz() would fail to return a valid result.

            I'm not trying to raise your hopes, as I can't see a solution anyway (if all you've said so far is true), but I think if it's clearer what you're talking about you may get lucky with someone else.

            Comment

            • dima69
              Recognized Expert New Member
              • Sep 2006
              • 181

              #7
              Originally posted by NeoPa
              I'm really trying to ask 'how' they are invisible here. On which objects (if any) do you set the visible property to False?
              If an object (control) were simply devoid of data I can't see why the Nz() would fail to return a valid result.

              I'm not trying to raise your hopes, as I can't see a solution anyway (if all you've said so far is true), but I think if it's clearer what you're talking about you may get lucky with someone else.
              The subreport is invisible because it has no data (even report's footer and header are invisible) - that's just the way it works. And there is no way to address any objects on that invisible subreport - as it does not exist at all. So you cannot just use NZ because any reference to empty subreport will produce an error.
              As for the solution - see my post above :)

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32662

                #8
                Nice one Dima :)
                I didn't realise it worked that way (I don't use sub-reports much as you can probably guess).
                Thanks for getting my back on this one.

                Comment

                • dima69
                  Recognized Expert New Member
                  • Sep 2006
                  • 181

                  #9
                  Originally posted by NeoPa
                  Nice one Dima :)
                  I didn't realise it worked that way (I don't use sub-reports much as you can probably guess).
                  Thanks for getting my back on this one.
                  Any time :)

                  Comment

                  • Zaher Rabah
                    New Member
                    • Apr 2007
                    • 13

                    #10
                    Originally posted by dima69
                    I am familiar with this problem. My solution is this:
                    1. In the main report module write a function
                    Code:
                    Function GetSubTotal(SubFRM as String) as Currency
                    On Error Goto Err1
                    GetSubTotal = Me(SubFRM)![sub total]
                    exit function
                    err1:
                    GetSubTotal = 0
                    end function
                    2. At the main form, put calculated field like this:
                    Code:
                    =GetSubTotal("SubFRM1")+GetSubTotal("SubFRM2")+GetSubTotal("SubFRM3")

                    Hi, Dima

                    Thank u for your help.

                    Regards

                    Zaher Rabah

                    Comment

                    Working...