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!

formula not working correctly. Please help

Status
Not open for further replies.

santosh1

Programmer
Apr 26, 2002
201
US
I have a a/c No. field for each item in the detail section.

For example:
Item
---------------------------------------
T Shirt
a/c: 6587-36580-9873-0000-0000

Poster
a/c: 6587-36580-9873-0000-0000

Brochure
a/c: 6587-36580-9873-0000-0000

Pens
a/c: 6587-36580-9873-0000-0000

If the a/c number is the same for all the items, then I want to display it at the top in the
page header section and suppress a/c in the detail section so that a/c no is displayed only once.
If a/c number is not the same for all line items, then display a/c no. at the detail section like above
and not show a/c number in the page header section.

To do this, I inserted three formula fields called @SameGL, @FlagSameGL and @EndSameGL.
I put @sameGL in the page header section, @FlagSameGL on the detail and @EndSameGL on the group footer
section.

Formula @sameGL has the following formula:

WhilePrintingRecords;
booleanVar sameGL := true


Formula @FlagsameGL has the following formula:
WhilePrintingRecords;
booleanVar sameGL ;

//If OnFirstRecord then //First record does not have a previous.
If {tglAccount.GLAcctNo} <> Next ({tglAccount.GLAcctNo}) Then
sameGL = false //Current and Next are matches
else If OnLastRecord Then //Last record does not have a Next.
If Previous( {tglAccount.GLAcctNo}) <> {tglAccount.GLAcctNo} Then
sameGL = false //Previous and Current 'match'.
Else If Previous( {tglAccount.GLAcctNo}) <> {tglAccount.GLAcctNo} OR {tglAccount.GLAcctNo} <> Next ( {tglAccount.GLAcctNo}) Then
sameGL = false //Checks Prevoius and Next record against Current record. (True)
else
sameGL = true


Finally, @EndsamGL has the following formula.

booleanVar sameGL ;



Finally, on detail section which shows the GL a/c, I did format section and suppressed this detail
section if boolean value for sameGL is true. However this method is not working. It shows GL a/c even
if the GL a/c no is same throughout the report.

Is there a different better way to do this? Thanks a lot.
 
You could accomplish something similar by creating a group on a/c number, and choosing &quot;Repeat Group Header on Each Page.&quot; You could conditionally suppress the group header based on:

count({table.groupfield},{table.groupfield}) = 1

Then use the same formula except change the operator to <> and use it to conditionally suppress the a/c number field in the details section.

-LB
 
Thanks LB for the info.

I am customizing this report which was originally written
by different vendor. The vendor's report engine overrides
my settings and doesn't allow me to group/sort on any field
on this particular report. The solution you mention requires grouping on a/c otherwise it would have been great. Is there any other way to resolve this than by grouping? Thanks a lot.

 
What do you want to happen if there are multiple lines with the same a/c number on half of the page and then a different a/c number for the rest of the page?

-LB
 
If there are multiple lines with same a/c number on half of the page and then diferent a/c number for the rest of the page, then I would display the a/c number on the detail line
as above like:

T Shirt
a/c: 6587-36580-9873-0000-0000

Poster
a/c: 6587-36580-9873-0000-0000

Brochure
a/c: 6587-36580-9873-0000-0000

Pens
T Shirt
a/c: 6587-36580-9873-0000-0000

Poster
a/c: 6587-36580-9873-0000-0000

Brochure
a/c: 6587-36580-9873-0000-0000

Pens
a/c: 6587-36580-9873-0000-0000


But if all the items on the report has the same a/c no., then I want to suppress the a/c no. from the detail section and just show a/c no. once at the header level as:

a/c no: 6587-36580-9873-0000-0000

Thanks a lot.


 
If there are multiple lines with same a/c number on half of the page and then diferent a/c number for the rest of the page, then I would display the a/c number on the detail line
as above like:

T Shirt
a/c: 6587-36580-9873-0000-0000

Poster
a/c: 6587-36580-9873-0000-0000

Brochure
a/c: 6587-36580-9873-0000-0000

Pens
T Shirt
a/c: 6587-36580-9873-0000-0000

Poster
a/c: 6587-36580-9873-0000-0000

Brochure
a/c: 6587-36580-9873-0000-0000

Pens
a/c: 6587-36580-9873-0000-0000


But if all the items on the report has the same a/c no., then I want to suppress the a/c no. from the detail section and just show a/c no. once at the header level as:

a/c no: 6587-36580-9873-0000-0000

Thanks a lot.
 
Why don't you just group by a/c number??

Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Jim,

I am not able to use group by/order by clause for this report since the report engine of the original vendor who wrote the report overwrites the group by/order by setting that I use otherwise it would have been great.
I am trying to customize their report. Any help appreciated.
Thanks.
 
show us how this report is currently grouped

Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
The above example was just an example.

Here's the SQL for the report. It was grouped by POKey when the vendor delivered the report.
I tried grouping by ItemID or tglAccount.glAccountNO, it doesn't group at all. Any other
way to check if the a/c no is same? Thanks for the help.

SELECT
tpoPurchOrder.&quot;UserFld1&quot;, tpoPurchOrder.&quot;UserFld2&quot;, tpoPurchOrder.&quot;UserFld3&quot;,
tpoPrintPOHdrWrk.&quot;SessionID&quot;, tpoPrintPOHdrWrk.&quot;POKey&quot;, tpoPrintPOHdrWrk.&quot;BuyerID&quot;, tpoPrintPOHdrWrk.&quot;CompanyID&quot;, tpoPrintPOHdrWrk.&quot;CompanyName&quot;, tpoPrintPOHdrWrk.&quot;CompanyAddr1&quot;, tpoPrintPOHdrWrk.&quot;CompanyAddr2&quot;, tpoPrintPOHdrWrk.&quot;CompanyAddr3&quot;, tpoPrintPOHdrWrk.&quot;CompanyAddr4&quot;, tpoPrintPOHdrWrk.&quot;CompanyCity&quot;, tpoPrintPOHdrWrk.&quot;CompanyState&quot;, tpoPrintPOHdrWrk.&quot;CompanyPhone&quot;, tpoPrintPOHdrWrk.&quot;CompanyPostalCode&quot;, tpoPrintPOHdrWrk.&quot;CompanyCountry&quot;, tpoPrintPOHdrWrk.&quot;CurrID&quot;, tpoPrintPOHdrWrk.&quot;FOB&quot;, tpoPrintPOHdrWrk.&quot;PmtTermsDesc&quot;, tpoPrintPOHdrWrk.&quot;PurchAmt&quot;, tpoPrintPOHdrWrk.&quot;PurchFromName&quot;, tpoPrintPOHdrWrk.&quot;PurchFromAddr1&quot;, tpoPrintPOHdrWrk.&quot;PurchFromAddr2&quot;, tpoPrintPOHdrWrk.&quot;PurchFromAddr3&quot;, tpoPrintPOHdrWrk.&quot;PurchFromAddr4&quot;, tpoPrintPOHdrWrk.&quot;PurchFromAddr5&quot;, tpoPrintPOHdrWrk.&quot;PurchFromCity&quot;, tpoPrintPOHdrWrk.&quot;PurchFromState&quot;, tpoPrintPOHdrWrk.&quot;PurchFromPostalCd&quot;, tpoPrintPOHdrWrk.&quot;PurchFromCountry&quot;, tpoPrintPOHdrWrk.&quot;RequestDate&quot;, tpoPrintPOHdrWrk.&quot;ChngOrdNo&quot;, tpoPrintPOHdrWrk.&quot;ShipMethID&quot;, tpoPrintPOHdrWrk.&quot;ShipToName&quot;, tpoPrintPOHdrWrk.&quot;ShipToAddr1&quot;, tpoPrintPOHdrWrk.&quot;ShipToAddr2&quot;, tpoPrintPOHdrWrk.&quot;ShipToAddr3&quot;, tpoPrintPOHdrWrk.&quot;ShipToAddr4&quot;, tpoPrintPOHdrWrk.&quot;ShipToAddr5&quot;, tpoPrintPOHdrWrk.&quot;ShipToCity&quot;, tpoPrintPOHdrWrk.&quot;ShipToState&quot;, tpoPrintPOHdrWrk.&quot;ShipToPostalCode&quot;, tpoPrintPOHdrWrk.&quot;ShipToCountry&quot;, tpoPrintPOHdrWrk.&quot;STaxAmt&quot;, tpoPrintPOHdrWrk.&quot;TranAmt&quot;, tpoPrintPOHdrWrk.&quot;TranCmnt&quot;, tpoPrintPOHdrWrk.&quot;TranDate&quot;, tpoPrintPOHdrWrk.&quot;TranNo&quot;, tpoPrintPOHdrWrk.&quot;TranTypeDescStrNo&quot;, tpoPrintPOHdrWrk.&quot;VendID&quot;,
tpoPrintPOLineWrk.&quot;SessionID&quot;, tpoPrintPOLineWrk.&quot;POLineKey&quot;, tpoPrintPOLineWrk.&quot;ExtAmt&quot;, tpoPrintPOLineWrk.&quot;ItemDesc&quot;, tpoPrintPOLineWrk.&quot;ItemID&quot;, tpoPrintPOLineWrk.&quot;POLineCmnt&quot;, tpoPrintPOLineWrk.&quot;POLineNo&quot;, tpoPrintPOLineWrk.&quot;QtyOrd&quot;, tpoPrintPOLineWrk.&quot;UnitCost&quot;, tpoPrintPOLineWrk.&quot;UnitMeasID&quot;,
NMDP_item_spec.&quot;nmdp_spec&quot;,
tglAccount.&quot;GLAcctNo&quot;
FROM
{ oj (((((&quot;SES_app&quot;.&quot;dbo&quot;.&quot;tpoPurchOrder&quot; tpoPurchOrder INNER JOIN &quot;SES_app&quot;.&quot;dbo&quot;.&quot;tpoPrintPOHdrWrk&quot; tpoPrintPOHdrWrk ON
tpoPurchOrder.&quot;POKey&quot; = tpoPrintPOHdrWrk.&quot;POKey&quot;)
INNER JOIN &quot;SES_app&quot;.&quot;dbo&quot;.&quot;tpoPrintPOLineWrk&quot; tpoPrintPOLineWrk ON
tpoPrintPOHdrWrk.&quot;SessionID&quot; = tpoPrintPOLineWrk.&quot;SessionID&quot; AND
tpoPrintPOHdrWrk.&quot;POKey&quot; = tpoPrintPOLineWrk.&quot;POKey&quot;)
INNER JOIN &quot;SES_app&quot;.&quot;dbo&quot;.&quot;tpoPrnPOLineDtlWrk&quot; tpoPrnPOLineDtlWrk ON
tpoPrintPOLineWrk.&quot;SessionID&quot; = tpoPrnPOLineDtlWrk.&quot;SessionID&quot; AND
tpoPrintPOLineWrk.&quot;POLineKey&quot; = tpoPrnPOLineDtlWrk.&quot;POLineKey&quot;)
LEFT OUTER JOIN &quot;SES_app&quot;.&quot;dbo&quot;.&quot;NMDP_item_spec&quot; NMDP_item_spec ON
tpoPrintPOLineWrk.&quot;ItemKey&quot; = NMDP_item_spec.&quot;itemKey&quot;)
INNER JOIN &quot;SES_app&quot;.&quot;dbo&quot;.&quot;tpoPOLineDist&quot; tpoPOLineDist ON
tpoPrnPOLineDtlWrk.&quot;POLineDistKey&quot; = tpoPOLineDist.&quot;POLineDistKey&quot;)
INNER JOIN &quot;SES_app&quot;.&quot;dbo&quot;.&quot;tglAccount&quot; tglAccount ON
tpoPOLineDist.&quot;GLAcctKey&quot; = tglAccount.&quot;GLAcctKey&quot;}
ORDER BY
tpoPrintPOHdrWrk.&quot;POKey&quot; ASC

 
I am not talking about the SQL ... I mean the report itself.



Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top