PC Review


Reply
Thread Tools Rate Thread

joining two queries.

 
 
DD
Guest
Posts: n/a
 
      26th Apr 2008
one query displays cases produced by item and raw material that should have
been used. second query displays what raw material was actually used.
sometimes not the same as what was called for. when i join these i get
duplicate cases produced when the raw material items do not match. is there
a way to prevent this.

thanks


 
Reply With Quote
 
 
 
 
Steve Schapel
Guest
Posts: n/a
 
      26th Apr 2008
DD,

In design view of the query, please select SQL from the VIew menu, and
then copy/paste the SQL view of the query into your reply. Thanks.

--
Steve Schapel, Microsoft Access MVP

DD wrote:
> one query displays cases produced by item and raw material that should have
> been used. second query displays what raw material was actually used.
> sometimes not the same as what was called for. when i join these i get
> duplicate cases produced when the raw material items do not match. is there
> a way to prevent this.
>
> thanks
>
>

 
Reply With Quote
 
 
 
 
DD
Guest
Posts: n/a
 
      28th Apr 2008
this is what i have. any help is appreciated.
QRyCASES



SELECT Repack.PJTDAT, [QryItem#].MNDESC, Repack.PJTCOD, Repack.PJPROD,
Sum(Repack.PJTQTY) AS SumOfPJTQTY, Repack.[PJORD#], Repack21.ABRLINE, [Bom
File].FFRAWC, [Bom File].MNDESC, [Bom File].FFSOLD, [Bom File].FFSOUM, [Bom
File].FFILSF, [SumOfPJTQTY]*[ffsold]*[ffilsf] AS [Std Qty]

FROM ((Repack INNER JOIN Repack21 ON Repack.[PJORD#] = Repack21.[ABTCK#])
LEFT JOIN [QryItem#] ON Repack.PJPROD = [QryItem#].[MNMFG#]) LEFT JOIN [Bom
File] ON Repack.PJPROD = [Bom File].FFFOID

WHERE (((Repack.PJTUM)="CASE"))

GROUP BY Repack.PJTDAT, [QryItem#].MNDESC, Repack.PJTCOD, Repack.PJPROD,
Repack.[PJORD#], Repack21.ABRLINE, [Bom File].FFRAWC, [Bom File].MNDESC,
[Bom File].FFSOLD, [Bom File].FFSOUM, [Bom File].FFILSF

HAVING (((Repack21.ABRLINE)<>"REW" And (Repack21.ABRLINE)<>"PRE" And
(Repack21.ABRLINE)<>"BKUP"))

ORDER BY Repack.PJTDAT;



QRYLBS

SELECT Repack.PJTDAT, [QryItem#].MNDESC, Repack.PJTCOD, Repack.PJPROD,
Sum(Repack.PJTQTY) AS SumOfPJTQTY, Repack.[PJORD#], Repack21.ABRLINE

FROM (Repack INNER JOIN Repack21 ON Repack.[PJORD#] = Repack21.[ABTCK#])
LEFT JOIN [QryItem#] ON Repack.PJPROD = [QryItem#].[MNMFG#]

WHERE (((Repack.PJTUM)="LB"))

GROUP BY Repack.PJTDAT, [QryItem#].MNDESC, Repack.PJTCOD, Repack.PJPROD,
Repack.[PJORD#], Repack21.ABRLINE

HAVING (((Repack21.ABRLINE)<>"REW" And (Repack21.ABRLINE)<>"PRE" And
(Repack21.ABRLINE)<>"BKUP"));





QRYREC



SELECT QryCases.[PJORD#], QryCases.[QryItem#].MNDESC, QryCases.PJPROD,
QryCases.SumOfPJTQTY, QryCases.ABRLINE, QryCases.FFRAWC, QryCases.[Std Qty],
QryLbs.PJPROD, QryLbs.MNDESC, QryLbs.SumOfPJTQTY

FROM QryCases LEFT JOIN QryLbs ON QryCases.[PJORD#] = QryLbs.[PJORD#]

WHERE (((QryCases.FFRAWC) Like "010*"));



Here are the results.



PJORD# QryCasesSumof FFRAWC STDQTY QryLBSPJPROD QRYLBSSUmOF

LBL0641970 844 01001023000 11,647 01001023000 13,000

LBL0641970 844 01001023000 11,647 01001039000 2,470



I left out some columns so it would be easier to read. The 844 and 11647
are doubled because and extra item was used to produced this order.





What I would like is





PJORD# QryCasesSumof FFRAWC STDQTY QryLBSPJPROD QRYLBSSUmOF

LBL0641970 844 01001023000 11,647 01001023000 13,000

LBL0641970 0 01001023000 0 01001039000 2,470




"Steve Schapel" <(E-Mail Removed)> wrote in message
news:eMLjL$%(E-Mail Removed)...
> DD,
>
> In design view of the query, please select SQL from the VIew menu, and
> then copy/paste the SQL view of the query into your reply. Thanks.
>
> --
> Steve Schapel, Microsoft Access MVP
>
> DD wrote:
>> one query displays cases produced by item and raw material that should
>> have been used. second query displays what raw material was actually
>> used. sometimes not the same as what was called for. when i join these i
>> get duplicate cases produced when the raw material items do not match.
>> is there a way to prevent this.
>>
>> thanks
>>


 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      29th Apr 2008
DD,

Thanks for the additional information.

I can't see any way to get the result you are asking for. Not directly
anyway.

It seems to me that in effect, there is a one-to-many relationship
between the data in the two base queries.

What is the purpose of this QRYREC query? If it's for a Report, then
you can use the report's Sorting & Grouping to get a group header on the
"cases" side, so that is only shown once, and then the "LBS" side can if
necessary show more than one item for the PJORD#.

Or if you will be outputting to a form, then possibly you need to
consider dropping the QRYREC query, and using a form/subform based on
the QRyCASES and QRYLBS queries respectively.

--
Steve Schapel, Microsoft Access MVP

DD wrote:
> this is what i have. any help is appreciated.
> QRyCASES
>
>
>
> SELECT Repack.PJTDAT, [QryItem#].MNDESC, Repack.PJTCOD, Repack.PJPROD,
> Sum(Repack.PJTQTY) AS SumOfPJTQTY, Repack.[PJORD#], Repack21.ABRLINE, [Bom
> File].FFRAWC, [Bom File].MNDESC, [Bom File].FFSOLD, [Bom File].FFSOUM, [Bom
> File].FFILSF, [SumOfPJTQTY]*[ffsold]*[ffilsf] AS [Std Qty]
>
> FROM ((Repack INNER JOIN Repack21 ON Repack.[PJORD#] = Repack21.[ABTCK#])
> LEFT JOIN [QryItem#] ON Repack.PJPROD = [QryItem#].[MNMFG#]) LEFT JOIN [Bom
> File] ON Repack.PJPROD = [Bom File].FFFOID
>
> WHERE (((Repack.PJTUM)="CASE"))
>
> GROUP BY Repack.PJTDAT, [QryItem#].MNDESC, Repack.PJTCOD, Repack.PJPROD,
> Repack.[PJORD#], Repack21.ABRLINE, [Bom File].FFRAWC, [Bom File].MNDESC,
> [Bom File].FFSOLD, [Bom File].FFSOUM, [Bom File].FFILSF
>
> HAVING (((Repack21.ABRLINE)<>"REW" And (Repack21.ABRLINE)<>"PRE" And
> (Repack21.ABRLINE)<>"BKUP"))
>
> ORDER BY Repack.PJTDAT;
>
>
>
> QRYLBS
>
> SELECT Repack.PJTDAT, [QryItem#].MNDESC, Repack.PJTCOD, Repack.PJPROD,
> Sum(Repack.PJTQTY) AS SumOfPJTQTY, Repack.[PJORD#], Repack21.ABRLINE
>
> FROM (Repack INNER JOIN Repack21 ON Repack.[PJORD#] = Repack21.[ABTCK#])
> LEFT JOIN [QryItem#] ON Repack.PJPROD = [QryItem#].[MNMFG#]
>
> WHERE (((Repack.PJTUM)="LB"))
>
> GROUP BY Repack.PJTDAT, [QryItem#].MNDESC, Repack.PJTCOD, Repack.PJPROD,
> Repack.[PJORD#], Repack21.ABRLINE
>
> HAVING (((Repack21.ABRLINE)<>"REW" And (Repack21.ABRLINE)<>"PRE" And
> (Repack21.ABRLINE)<>"BKUP"));
>
>
>
>
>
> QRYREC
>
>
>
> SELECT QryCases.[PJORD#], QryCases.[QryItem#].MNDESC, QryCases.PJPROD,
> QryCases.SumOfPJTQTY, QryCases.ABRLINE, QryCases.FFRAWC, QryCases.[Std Qty],
> QryLbs.PJPROD, QryLbs.MNDESC, QryLbs.SumOfPJTQTY
>
> FROM QryCases LEFT JOIN QryLbs ON QryCases.[PJORD#] = QryLbs.[PJORD#]
>
> WHERE (((QryCases.FFRAWC) Like "010*"));
>
>
>
> Here are the results.
>
>
>
> PJORD# QryCasesSumof FFRAWC STDQTY QryLBSPJPROD QRYLBSSUmOF
>
> LBL0641970 844 01001023000 11,647 01001023000 13,000
>
> LBL0641970 844 01001023000 11,647 01001039000 2,470
>
>
>
> I left out some columns so it would be easier to read. The 844 and 11647
> are doubled because and extra item was used to produced this order.
>
>
>
>
>
> What I would like is
>
>
>
>
>
> PJORD# QryCasesSumof FFRAWC STDQTY QryLBSPJPROD QRYLBSSUmOF
>
> LBL0641970 844 01001023000 11,647 01001023000 13,000
>
> LBL0641970 0 01001023000 0 01001039000 2,470

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help-Joining two tables from two Access databases =?Utf-8?B?Um95?= Microsoft ADO .NET 1 24th Jun 2006 01:56 AM
Managing Conversations: manually joining two threads =?Utf-8?B?aHVnZWhlYWQ=?= Microsoft Outlook Discussion 2 31st Mar 2005 10:25 AM
Joining/appending two columns of data Richard Edwards Microsoft Excel Discussion 3 27th Jul 2004 09:49 AM
Joining two movies CW Windows XP MovieMaker 3 5th Mar 2004 10:43 AM
joining two computers together in a network one xp other 98s al Windows XP Networking 2 30th Nov 2003 09:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:09 AM.