0
votes

I am trying to set a couple of global variables in a subreport so that it pulls and stores the data I need in each.

Say I go into the formula workshop and create a new formula. Right now I have

Global numbervar name:= ; 

I have a single table with multiple fields. I have one field named {table.order} and another named {table.amount}. Both of these are numbers. How do I assign to this variable the amount in the associated amount field when the order is -1? I'm really not familiar with crystal syntax at all.

After this, where would I need to drag and drop this formula in the report to pick up this data or is simply creating the formula in the formula explorer enough? If it needs to be physically dragged into the report, will anything show up or will I need to suppress it so it is not visible and if that is the case, will it still work suppressed? Thanks for any help you can give.

1
Also, how do I call this variable later? - Nard Dog

1 Answers

1
votes

Are you trying to pass the value in this variable back to the main report? If so, you'll need to make this a Shared Numbervar, not a Global Numbervar.

To answer your question; create this formula:

global numbervar name;
if {table.order} = -1 then name := {table.amount}

...and drop it into your subreport's details section. Note that any formulas, summaries, running totals, SQL expressions, etc. that you create but are not placed in the actual report won't be run. However, after placing it in the report, it will display. To prevent this, right click on the field, go to the 'Common' tab, and then check 'Suppress'. The formula will still work when suppressed.

One other thing to keep in mind is that if your subreport(s) contain more than one row of data, the variable will be overwritten for each.