Tips and Tricks
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Tips and Tricks
Message Icon Topic: Totaling with a cuple of 1 to Many relationships Post Reply Post New Topic
Page  of 2 Next >>
Author Message
DoubleD
Newbie
Newbie


Joined: 26 Sep 2012
Online Status: Offline
Posts: 17
Quote DoubleD Replybullet Topic: Totaling with a cuple of 1 to Many relationships
    Posted: 19 Mar 2014 at 5:10am
I need to write a report that includes a  one to many relationship on two tables

I started simple access the table with one (inventory) I link it to a table with a 1 to many relationship (InvMovement)

I group  on and to  sum on qty move  - Life is good

Then I add the warehouse table so I can figure out how many items I have on hand. Yup its a one to many so now I have 2 one to many relationships here  (1 to many to many)

Needless to say my totals are all whacked out. I can get one side or the other to total OK but not both.

Given the tables

INV
1
2

INV Movement
1         10
1         20
2         15

INV  Warehouse     QTY
1            A                  3
1            B                  5
1            C                  2
2            A                  10
2            B                  10

In Crystal when I link them all together I get a complex that looks like this

Inv    Move  WH    QTY
1          10      A      3
1          10      B      5
1          10      C      2
1          20      A      3
1          20      B      5
1          20      C      2
2          15      A      10
2          15      B      10


The report should show

INV    Tot Moved    On hand
1            30                 10
2            15                 20


How would you go about making the report total correctly  I get a total of 90 movements for INV 1 and 20 on hand  

For inv 2 I get total movement of 30 and a qty of 20
IP IP Logged
otto
Groupie
Groupie


Joined: 17 Mar 2014
Online Status: Offline
Posts: 53
Quote otto Replybullet Posted: 19 Mar 2014 at 5:15am
Are you linking INV Warehouse and INV Movement to INV?
IP IP Logged
DoubleD
Newbie
Newbie


Joined: 26 Sep 2012
Online Status: Offline
Posts: 17
Quote DoubleD Replybullet Posted: 19 Mar 2014 at 5:29am
Originally posted by otto

Are you linking INV Warehouse and INV Movement to INV?


Cyrstal defaults the links  but I deleted them all and made them

INV link partno to partno left outer join to INV Movement and
INV link partno to partno left outer join to INV Warehouse

So I think the answer to your question is Yes
IP IP Logged
otto
Groupie
Groupie


Joined: 17 Mar 2014
Online Status: Offline
Posts: 53
Quote otto Replybullet Posted: 19 Mar 2014 at 5:36am
you should not link more than one table to a field because it will open those tables at the same time and it will duplicate, triplicate you data. Try linking INV to Inv Movement and then Inv Mov to Inv warehouse, then group by INV and do the summary
IP IP Logged
otto
Groupie
Groupie


Joined: 17 Mar 2014
Online Status: Offline
Posts: 53
Quote otto Replybullet Posted: 19 Mar 2014 at 5:46am
If that does not work you can put Inv Warehouse table in a subreport linked to INV by INV, so in the main report you will have INV and Inv Movement, there do a group by INv, put there the INV, the summary by move and the subreport, in the subreport make a gruop by INV as well and put on that gruop the summary by QTY
IP IP Logged
DoubleD
Newbie
Newbie


Joined: 26 Sep 2012
Online Status: Offline
Posts: 17
Quote DoubleD Replybullet Posted: 19 Mar 2014 at 5:54am
Originally posted by otto

If that does not work you can put Inv Warehouse table in a subreport linked to INV by INV, so in the main report you will have INV and Inv Movement, there do a group by INv, put there the INV, the summary by move and the subreport, in the subreport make a gruop by INV as well and put on that gruop the summary by QTY



Originally posted by I was just about to post


I'm new to crystal reports and I just can't figure this out.

I can get it to work if I link just INV  and INV Movements  or
just INV and INV Warehouse I may just write two reports. One for QTY on hand and the other for total movements. Then I'll export the reports to excel then use a vlookup to pull in the data into one sheet


There has to be a way to do this in crystal but I




Clap OMG I forgot all about subreports - I actually did something like this a while back but I only did it once and if you don't use it you lose it. OK now to remember how - Better go look at my old report

Thanks

I'll post back if it works




Edited by DoubleD - 19 Mar 2014 at 5:57am
IP IP Logged
DoubleD
Newbie
Newbie


Joined: 26 Sep 2012
Online Status: Offline
Posts: 17
Quote DoubleD Replybullet Posted: 19 Mar 2014 at 6:04am
Originally posted by otto

you should not link more than one table to a field because it will open those tables at the same time and it will duplicate, triplicate you data. Try linking INV to Inv Movement and then Inv Mov to Inv warehouse, then group by INV and do the summary


I may not have a movement for every piece of inventory so wouldn't I  drop records by linking like this ?
IP IP Logged
otto
Groupie
Groupie


Joined: 17 Mar 2014
Online Status: Offline
Posts: 53
Quote otto Replybullet Posted: 19 Mar 2014 at 7:02am
then link INV to INV ware and INV ware to INV move. Did you try doing the subreport?
IP IP Logged
DoubleD
Newbie
Newbie


Joined: 26 Sep 2012
Online Status: Offline
Posts: 17
Quote DoubleD Replybullet Posted: 19 Mar 2014 at 7:12am
Thumbs%20Up  Otto The Subreport worked
Thank you ever so much for reminding me

I am interested in your previous post about linking INV to INV MOVEMENT and INV MOVEMENT to INV WAREHOUSE  - Would that really work? Wouldn't it drop records . I want data for verything in my inventory - if I have no movement would the outer join still bing in the INV record so that I can find anything in the warehouse table - I may have to  experiment with this after I satisfy the client request.




Ooops  may have to switch the link and sub report I think I'm dropping stuff but 'm sooo much closer now


Tanks a again


Edited by DoubleD - 19 Mar 2014 at 7:13am
IP IP Logged
otto
Groupie
Groupie


Joined: 17 Mar 2014
Online Status: Offline
Posts: 53
Quote otto Replybullet Posted: 19 Mar 2014 at 7:24am
you should do an inner join in order to populate all the records you have.
IP IP Logged
Page  of 2 Next >>
Post Reply Post New Topic
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



This page was generated in 0.015 seconds.