Results 1 to 6 of 6

Thread: Passing value from Sub-Report to Main-Report

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2003
    Posts
    10

    Passing value from Sub-Report to Main-Report

    Can anyone please help me...
    Did anyone know how to pass a sum value (or any value) from Sub-Report to Main-Report?
    I mean pass it to a formular or parameter, not just view it on Main-Report.

    Please and Thank you.

    I am using Crystal Report 8.0 and Ms Access Database.
    Report Connection : ODBC Connection.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    You need to use a Shared variable.

    In the subreport create a formula that contains/calculates the value you want to pass across. Something like
    Code:
    Shared currencyVar TotalAmount := Sum ({[Order Details].Amount});
    In the main report create a formula that uses this shared variable. Something like

    Code:
    Shared currencyVar TotalAmount;
    
    If TotalAmount > 1000 then 
       TotalAmount * .1
    Else 
       TotalAmount * .05
    Both formulas must use the exact same variable declaration. See the help file for more info on creating variables.
    Last edited by brucevde; Sep 16th, 2003 at 03:18 PM.

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2003
    Posts
    10
    Thanks for your reply brucevde. These code really help me a lot and I think this is very cool. (about the Shared Var)

  4. #4
    New Member
    Join Date
    Nov 2007
    Posts
    3

    Unhappy Re: Passing value from Sub-Report to Main-Report

    Hi.

    Sorry about my lack of knowledge, but how do you declare the variable? I don't really use VBA, so where do you do that? It keeps giving me this error:

    Compile error:

    Expected: line number or label or statement or end of statement

    =======================

    Here's my code (I just pasted yours above Option Compare Database)

    Code:
    Shared currencyVar TotalAmount := Sum ({[Order Details].Amount});
    
    Option Compare Database
    Thanks

  5. #5
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Passing value from Sub-Report to Main-Report

    The code shown is used in Crystal Reports and has nothing to do with VBA.

  6. #6
    New Member
    Join Date
    Nov 2007
    Posts
    3

    Re: Passing value from Sub-Report to Main-Report

    Sorry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width