Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula Field/Sub Report Question Post Reply Post New Topic
Page  of 2 Next >>
Author Message
pjewett
Newbie
Newbie


Joined: 22 Mar 2013
Online Status: Offline
Posts: 8
Quote pjewett Replybullet Topic: Formula Field/Sub Report Question
     Posted: 25 Mar 2013 at 4:41am
Hi All,

New to the forum and this is my first post. I'm learning Crystal/SQL on demand so to speak. I'll try to be clear as possible with my semi/newbie question.

I have an existing Crystal Report that is our Purchase Order and it "hangs" off of or is aliased from a 3rd Party Publishing biblio db.

Currently the "Vendor" area of the PO is pulling in vendor name, address, etc from our vendor table. That's great. However some of our vendors may be the ones getting the PO (and need to be on the PO) but a different "affiliated" company may be the "Payee."

When we set up a new vendor in our db we have the option of linking another vendor to the new entry as the "payee."  The primary vendor gets a unique "vendorkey" and in the case of the assignment of a "payee" a unique value is placed in the "paytovendorkey" field for the vendor record. That "paytovendorkey" is actually also a "vendorkey"...that of the "payee."

Utilizing some space on the canvas under the "Vendor" area of the PO I need to create either a formula field or subreport (whichever is easiest/best) that will (when applicable) pull the "Payee" vendor name, address etc. from the same vendor table that "Vendor" is pulled from. It would be first looking at the record for the "Vendor" in the vendor table to see if there is a key in the "paytovendorkey" field.....and then referencing the vendor table for that key in the "vendorkey" field to pull that vendors record.

Make sense?

Something like (but not complete of course)

if gpo.vendorkey=vendor.vendorkey
then vendor.name=vendor.paytovendorkey=vendor.vendorkey

I know this is incomplete and not correct but hoping my explanation of what I'm trying to do will be enough for a pro to help!

:)

Thanks in advance.


IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Mar 2013 at 4:51am
you do not create the link/join in a formula.
You can add the new table to the report and join/link it on the field you need to. Since not all vendors will have a matching record in this new table make sure to out join then so you will eb selectng all fioeld from your current vendor table.
in the report you can add a that data as you desire and conditionally suppress the secion if you need to
isnull(newtable.vendorid)
IP IP Logged
pjewett
Newbie
Newbie


Joined: 22 Mar 2013
Online Status: Offline
Posts: 8
Quote pjewett Replybullet Posted: 25 Mar 2013 at 5:29am
Originally posted by DBlank

you do not create the link/join in a formula.
You can add the new table to the report and join/link it on the field you need to. Since not all vendors will have a matching record in this new table make sure to out join then so you will eb selectng all fioeld from your current vendor table.
in the report you can add a that data as you desire and conditionally suppress the secion if you need to
isnull(newtable.vendorid)


Hmmm..not sure I'm able to apply this to what I'm doing but as mentioned I'm a newbie.

Maybe if I expand on this or am more specific.

Basically (insofar as vendor info is concerned) this Crystal Report is fed by our PO table (gpo).  So a record (an individual PO) in our GPO table has among other things the "primary" vendor info (name, address, etc) for the specific Purchase order and this is includes the vendors "vendorkey."

(When a PO is created by the user and thusly a record in the GPO table it pulls the primary vendor info from our VENDOR table and it becomes part of the record.)

What I've done is actually add the VENDOR table to the Crystal Report joining to the GPO table on vendorkey.

When a PO is printed from our system for a given ISBN (we're a book publisher) the vendor that was assigned to the PO by the user populates in the "Vendor" part of the PO. Name, address, etc.

So what I think I want to do is to produce a section for a "Payee" (which is just another vendor associated with the primary) by referencing the record for the PO...specifically the "vendorkey"...look it up so to speak in the newly added VENDOR table....see if there is a value in that records "paytovendorkey" field and then use that key (which is actually a vendor key) to look up this second vendor in the VENDOR table and populate it's name, address, etc.

Hope that clarifies rather than obscures what I'm trying to do.




Edited by pjewett - 25 Mar 2013 at 5:31am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Mar 2013 at 5:43am

so you have a PO table that is joined to the vendor table but in certain cases their is a "secondary vendor" used ('payee') that you also want to print.

You have to add the vendor table to the report a second time. It will add _1 to the end of the name (Vendor_1) whne you do this.
You have to outer join the Vendor_1 tabnle to the PO on this paytovendorkey field, otherwise it will exclude the PO's that do not have both a "po vendor" and a "po payee".
IP IP Logged
pjewett
Newbie
Newbie


Joined: 22 Mar 2013
Online Status: Offline
Posts: 8
Quote pjewett Replybullet Posted: 25 Mar 2013 at 5:50am
Originally posted by DBlank

so you have a PO table that is joined to the vendor table but in certain cases their is a "secondary vendor" used ('payee') that you also want to print.

You have to add the vendor table to the report a second time. It will add _1 to the end of the name (Vendor_1) whne you do this.
You have to outer join the Vendor_1 tabnle to the PO on this paytovendorkey field, otherwise it will exclude the PO's that do not have both a "po vendor" and a "po payee".


The vendor table wasn't originally included in the report (vendor info was inserted from the it into the GPO table by a db process) I added it knowing I needed to but that's as far as I got.

Do I need to add it a 2nd time or can I make join to the gpo table from the 1st instance of the vendor table...gpo.vendorkey to vendor.paytovendorkey
IP IP Logged
pjewett
Newbie
Newbie


Joined: 22 Mar 2013
Online Status: Offline
Posts: 8
Quote pjewett Replybullet Posted: 25 Mar 2013 at 6:11am
So I've added the vendor table to this crystal report joining it left outer vendor.vendorkey to gpo.vendorkey.

When I add the "paytovendorkey" field to the report  and run it I do in fact get the appropriate "Payee" vendorkey for the "primary" Vendor that already appears on the report.

Just can't get any of the other info for that paytovendor to appear....frustrating.

Will understand if you give up but thanks for the help thus far.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Mar 2013 at 6:19am

you should have a vendor table and a vendor_1 table, correct?

vendor table is where you will get all of the 'po vendor' fields from
vendor_1 table is where you will get all of the 'po payee' fields from
 
Does that help?
IP IP Logged
pjewett
Newbie
Newbie


Joined: 22 Mar 2013
Online Status: Offline
Posts: 8
Quote pjewett Replybullet Posted: 25 Mar 2013 at 6:31am
Originally posted by DBlank

you should have a vendor table and a vendor_1 table, correct?

vendor table is where you will get all of the 'po vendor' fields from
vendor_1 table is where you will get all of the 'po payee' fields from
 
Does that help?


That's what I believe I have but not working. Currently I have...

Added the vendor table twice to this report....the first instance is a left outer join vendor.vendorkey to gpo.vendorkey.

The second instance (vendor_1) is joined vendor_1.paytovendorkey to gpo.vendorkey and I'm so far trying to bring in just the name & paytovendorkey of the "payee" vendor from this table but nothing comes up at all on a right outer. A left outer not only doesn't give me "payee" vendor info but the primary vendor info on the report (that comes from gpo table) doesn't appear either. Same for an inner join.
IP IP Logged
pjewett
Newbie
Newbie


Joined: 22 Mar 2013
Online Status: Offline
Posts: 8
Quote pjewett Replybullet Posted: 25 Mar 2013 at 6:37am

IP IP Logged
pjewett
Newbie
Newbie


Joined: 22 Mar 2013
Online Status: Offline
Posts: 8
Quote pjewett Replybullet Posted: 25 Mar 2013 at 6:42am
IP IP Logged
Page  of 2 Next >>
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum