hyosafi
hyosafi

Reputation: 23

Crystal Reports - Help displaying multiple Report Fields with one Formula

I am not a programmer by any means. I am but a curious lowly administrator attempting to modify a report for my needs. I have a Crystal Reports .rpt file that shows Purchase Orders and payments against those purchase orders. My problem is that the payment lines don't reference the purchase order number. Currently, I have to export the report then go through in excel and manually match each AP line to its matching Purchase Order number. I would like the AP line to also show the Purchase Order number.

There is a field in the report called "@Voucher_PO_ID" with the following formula in it:

if {LAGL019Q.RECORD_TYPE} = "3" then
   if {LAGL019Q.SOURCE} = "AP" then
     {LAGL019Q.TRANS_REF_NUM}
   else if {LAGL019Q.SOURCE} = "PO" or {LAGL019Q.SOURCE} = "RQ" then
             {LAGL019Q.PO_ID}
    else " "
else " "

As I understand it, this formula is saying if the SOURCE is an AP (accounts payable) then for that line show the TRANS_REF_NUM (the check number for the payment), but if the SOURCE is a PO (purchase order) then show PO_ID (the purchase order number).

Again, knowing very little about programming, I was hoping it would be something as simple as modifying the if then statement to:

   if {LAGL019Q.SOURCE} = "AP" then
     {LAGL019Q.TRANS_REF_NUM} and {LAGL019Q.PO_ID}

But this does not work. I can append some text to the end of {LAGL019Q.TRANS_REF_NUM} by adding {LAGL019Q.TRANS_REF_NUM} + "blah" so I'm not sure why it won't add another field.

It just won't let me change this part of the formula:

"   if {LAGL019Q.SOURCE} = "AP" then
     {LAGL019Q.TRANS_REF_NUM}"

If I simply try:

   if {LAGL019Q.SOURCE} = "AP" then
     {LAGL019Q.PO_ID}

It still won't work and I'm not sure why? IF its an accounts payable line, I want it to show the corresponding PO_ID. It just shows a blank field when I do this even though I know the AP line has a corresponding PO.

I'm guessing there is some larger thing I am unaware of regarding how the actual database is setup. Maybe AP lines don't actually reference the PO_ID and I'm just assuming they do.

Most google searches I did brought be back here so I thought I'd post my problem. I've searched similar questions and they are mostly out of my league. Thanks ahead for any suggestions.

Upvotes: 2

Views: 1649

Answers (1)

Ryan
Ryan

Reputation: 7287

I think your only problem is that you're trying to use a logical operator (the AND keyword) instead of a string operator (The + or & characters). Hopefully it's as simple as this:

if {LAGL019Q.RECORD_TYPE} = "3" then
   if {LAGL019Q.SOURCE} = "AP" then
     "This is the transaction#: " + {LAGL019Q.TRANS_REF_NUM} + 
     ", and this is the PO ID: " + {LAGL019Q.PO_ID}
   else if {LAGL019Q.SOURCE} = "PO" or {LAGL019Q.SOURCE} = "RQ" then
             {LAGL019Q.PO_ID}
    else " "
else " "

If the {LAGL019Q.PO_ID}="AP" then this should result in:

This is the transaction#: <TheActualNumber>, and this is the PO ID: <TheActualPOID>

EDIT1: One other thought: How sure are you that the database actually holds valid PO#s for these records? If you tried to use if {LAGL019Q.SOURCE} = "AP" then {LAGL019Q.PO_ID} and it turned up blank, then that's a pretty good indicator that {LAGL019Q.PO_ID} is actually null for that record.

Upvotes: 0

Related Questions