Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing shared variable to main report (Problem on first record)

Status
Not open for further replies.

ramc2000

Technical User
Nov 8, 2002
60
GT
I have a report where I'm passing the value of a shared variable from a subreport to the main report and it's working as expected... almost every time... the only problem I'm seeing is in the very first record of the main report, in this case the shared variable seems to be blank. Here's a description of what I'm doing:

I have to report the total quantities for every item picked from our distribution center in a given day, this data is displayed on my main report. On my subreport I'm displaying any quantities of the item that may or may not have been returned to stock on account of a customer cancelling the order.

GH1 {Item Number}:
- Subreport (put here only for the purpose of pulling the variable value to the main report, the subreport is actually minimized, not suppressed).

The subreport contains this formula (@Returned)

whileprintingrecords;
shared numbervar ReturnedQty;
ReturnedQty:=Sum ({Returned Quantity},{Item Number})

GF1:
- Summary: Sum({PickQty}, {Item})
- Formulas @ReturnedQty and @ResetReturnedQty

@ReturnedQty
whileprintingrecords;
shared numbervar Returned;
ReturnedQty;

@ResetReturnedQty
shared numbervar ReturnedQty;
ReturnedQty:=0

This is working fine every time except when for the very first record of the main report there happens to be a returned qty. The returned qty should be displayed on the main report but instead it's showing as blank.

Here's a sample of what I'm seeing:

Item Pick Qty Return Qty
123 10
124 5 9
125 6
126 5 10

When it should be:

Item Pick Qty Return Qty
123 10 2
124 5 9
125 6
126 5 10


 
Make sure that @ReturnedQty is in GF_a and the reset formula is in GF_b and in the RH (in case of null returns on the first item).

-LB
 
I inserted a new section below GF1... I then did move the reset formula to GF1b and also copied it to the report header. First record still showing up as blank.

 
It should at least show 0 if it has a null value. You don't happen to have any conditional suppression on the Group Header section, do you?

-LB
 
I double checked that I don't have any conditional suppresion... and yes you are correct, the values are showing as 0 (not blank), my mistake.
 
Are the correct shared values showing for the other item groups? They are not off by one item, are they?

-LB
 
The subreport is linked on the item number, correct? Not sure this matters, but in the subreport, place the shared variable formula in the subreport report footer. You could also remove the group condition in the formula, since it will only evaluate records for that item number. Again, that shouldn't affect the results though.

-LB
 
Yes, linked on the item number.
I tried placing the shared variable formula on the report footer in the subreport but still shows up as 0 on the main one.
I also tried removing the group condition like you suggested... still no luck.
 
What is your actual formula for:

whileprintingrecords;
shared numbervar ReturnedQty;
ReturnedQty:=Sum ({Returned Quantity},{Item Number})

Is {Returned Quantity} a calculated formula and not a database field? If so, what is the content?

Also, if you run the subreport on its own, do you get a value for the first item?

-LB
 
Sorry I had to leave yesterday....Thank you for staying with me on this one.

This is the actual formula:

whileprintingrecords;
shared numbervar ReturnedQty;
ReturnedQty:=Sum ({TRHRETNSTK.QTY}, {TRHRETNSTK.ITM_NUM})

I also tried removing the group condition like you suggested to no avail.
I tried to run the subreport on its own... when I do I get the result I want! but on the main report it's still zero.
 
I found the problem! Your question about whether I was linking by the item field gave the problem away... I guess because I was trying to keep my post from becoming too complex I didn't mention there was another group both on the subreport and the main report (order number). What I did was move the subreport to group header 2. Again, thank you for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top