PC Review


Reply
Thread Tools Rate Thread

aggregate calculation works in select query but not an update quer

 
 
bicyclops
Guest
Posts: n/a
 
      27th May 2010
The below query works well as a Select Query. But when I turn it into an
update query, I get a whole lot of nothing in the results.

Interestingly, if I try to call this query from a Macro on my form, I get
error (-20324) repeated the number of times that there are records in the
query.

It was designed to go into a table of price breaks & decide whether the
quantities being ordered meet the price breaks. It then takes either that
adjusted price, or the original price & populate the values into a table.

Select Query:
SELECT QryBOMDetails2.ParentBOMID, QryBOMDetails2.BOMPrice,
IIf(IsNull(DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" & [MfrPNID] & "And
[Level]<=" &
[ExtQty])),[mfrbaseprice],DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" &
[MfrPNID] & "And [Level]<=" & [ExtQty])) AS q
FROM QryBOMDetails2
WHERE (((QryBOMDetails2.ParentBOMID)=[Forms]![FrmBOMEntry]![TxtBOMID]) AND
((QryBOMDetails2.BOMPrice) Is Null));

Update Query:
UPDATE QryBOMDetails2 SET QryBOMDetails2.BOMPrice =
IIf(IsNull(DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" & [MfrPNID] & "And
[Level]<=" &
[ExtQty])),[mfrbaseprice],DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" &
[MfrPNID] & "And [Level]<=" & [ExtQty]))
WHERE (((QryBOMDetails2.BOMPrice) Is Null) AND
((QryBOMDetails2.ParentBOMID)=[Forms]![FrmBOMEntry]![TxtBOMID]));

FYI I'm doing this using the query builder.
Thanks in advance for any advice.


 
Reply With Quote
 
 
 
 
bicyclops
Guest
Posts: n/a
 
      27th May 2010
OK; I guess it's back to the drawing board; thanks.

"Jerry Whittle" wrote:

> I'm very surprised that the query below is updateable when attached to a
> form. There's multiple Right and Left Joins and some functions which would
> keep those fields from being updated. TblBOMDetails seems to be joined a
> bunch of different ways to other tables.
>
> If this complicate query is updateable, then it's just possible that basing
> an update query on it is just too much for Access to handle.
> --
> Jerry Whittle, Microsoft Access MVP
> Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
>
>
> "bicyclops" wrote:
>
> > QryBOMDetails2 is a biggie. But it's also attached to a form & normally
> > updates with no problem. Sql is below.
> >
> > SELECT TblBOMDetails.LineItem, TblBOMDetails.BOMDetailID,
> > TblBOMDetails.PartNumID, TblBOMDetails.ChildBOMID, [PartPrefix] & "-" &
> > Format([Part#Suffix],"0000") AS [ItemPart#], TblBOMDetails.ParentBOMID,
> > TblBOMDetails.Qty, TblBOMDetails.OverBuyQty, TblBOMDetails.Refdes,
> > TblComps.Description, TblPartPrefix.[Prefix Description],
> > TblBOMDetails.MfrPNID, TblMFRPN.MFRPNPart, TblMFR.MFRMfrName,
> > TblMFRPN.MFRDesc, TblMFRPN.Price AS MfrBasePrice, TblBOMDetails.VendorPNID,
> > TblVendorPN.VendorID, TblVendor.SUSupplier, TblVendorPN.VendorPN,
> > TblBOMDetails.CustPNID, TblCompanies.CompanyName, TblCustPN.CustPN,
> > TblBOMDetails.SourceFromVendor, TblBOMDetails.VendorSourceQty,
> > TblBOMDetails.SourceFromCust, TblBOMDetails.CustSourceQty,
> > TblBOMDetails.SourceFromMfr, TblBOMDetails.MfrSourceQty,
> > TblBOMDetails.SourceFromStock, TblBOMDetails.StockSourceQty,
> > TblComps.StockQty, TblBOM.BuildQty,
> > (Nz([BuildQty],1)*[Qty])+(Nz([OverBuyQty],0)) AS ExtQty, TblComps.UnitsID,
> > TblUnits.BuyAs, TblBOMDetails.Price AS BOMPrice, TblBOMDetails.MfrPNTemp,
> > TblVendor.SUID,
> > IIf([ExtQty]<>(Nz([VendorSourceQty],0))+(Nz([CustSourceQty],0))+(Nz([MfrSourceQty],0))+(Nz([StockSourceQty],0)),1,0) AS QtyMismatchFlag
> > FROM TblVendor RIGHT JOIN (TblVendorPN RIGHT JOIN (TblUnits RIGHT JOIN
> > (TblPartPrefix RIGHT JOIN (TblMFR RIGHT JOIN ((TblCompanies RIGHT JOIN
> > TblCustPN ON TblCompanies.CompanyID = TblCustPN.CustID) RIGHT JOIN (TblBOM
> > RIGHT JOIN ((TblComps RIGHT JOIN TblBOMDetails ON TblComps.[Part#ID] =
> > TblBOMDetails.PartNumID) LEFT JOIN TblMFRPN ON TblBOMDetails.MfrPNID =
> > TblMFRPN.MFRPNID) ON TblBOM.BOMID = TblBOMDetails.ParentBOMID) ON
> > TblCustPN.CustPNID = TblBOMDetails.CustPNID) ON TblMFR.MFRID =
> > TblMFRPN.MFRPNMFRID) ON TblPartPrefix.PartPrefixID = TblComps.PartPrefixID)
> > ON TblUnits.ID = TblComps.UnitsID) ON TblVendorPN.VendorPNID =
> > TblBOMDetails.VendorPNID) ON TblVendor.SUID = TblVendorPN.VendorID
> > ORDER BY TblBOMDetails.LineItem;
> >
> >
> > "Jerry Whittle" wrote:
> >
> > > > QryBOMDetails2
> > >
> > > We probably need to see the sql for it. There's many reasons why a query
> > > isn't updateable.
> > >
> > > BTW: Check out my signature line!
> > > --
> > > Jerry Whittle, Microsoft Access MVP
> > > Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
> > >
> > >
> > > "bicyclops" wrote:
> > >
> > > > The below query works well as a Select Query. But when I turn it into an
> > > > update query, I get a whole lot of nothing in the results.
> > > >
> > > > Interestingly, if I try to call this query from a Macro on my form, I get
> > > > error (-20324) repeated the number of times that there are records in the
> > > > query.
> > > >
> > > > It was designed to go into a table of price breaks & decide whether the
> > > > quantities being ordered meet the price breaks. It then takes either that
> > > > adjusted price, or the original price & populate the values into a table.
> > > >
> > > > Select Query:
> > > > SELECT QryBOMDetails2.ParentBOMID, QryBOMDetails2.BOMPrice,
> > > > IIf(IsNull(DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" & [MfrPNID] & "And
> > > > [Level]<=" &
> > > > [ExtQty])),[mfrbaseprice],DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" &
> > > > [MfrPNID] & "And [Level]<=" & [ExtQty])) AS q
> > > > FROM QryBOMDetails2
> > > > WHERE (((QryBOMDetails2.ParentBOMID)=[Forms]![FrmBOMEntry]![TxtBOMID]) AND
> > > > ((QryBOMDetails2.BOMPrice) Is Null));
> > > >
> > > > Update Query:
> > > > UPDATE QryBOMDetails2 SET QryBOMDetails2.BOMPrice =
> > > > IIf(IsNull(DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" & [MfrPNID] & "And
> > > > [Level]<=" &
> > > > [ExtQty])),[mfrbaseprice],DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" &
> > > > [MfrPNID] & "And [Level]<=" & [ExtQty]))
> > > > WHERE (((QryBOMDetails2.BOMPrice) Is Null) AND
> > > > ((QryBOMDetails2.ParentBOMID)=[Forms]![FrmBOMEntry]![TxtBOMID]));
> > > >
> > > > FYI I'm doing this using the query builder.
> > > > Thanks in advance for any advice.
> > > >
> > > >

 
Reply With Quote
 
Jerry Whittle
Guest
Posts: n/a
 
      27th May 2010
> QryBOMDetails2

We probably need to see the sql for it. There's many reasons why a query
isn't updateable.

BTW: Check out my signature line!
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"bicyclops" wrote:

> The below query works well as a Select Query. But when I turn it into an
> update query, I get a whole lot of nothing in the results.
>
> Interestingly, if I try to call this query from a Macro on my form, I get
> error (-20324) repeated the number of times that there are records in the
> query.
>
> It was designed to go into a table of price breaks & decide whether the
> quantities being ordered meet the price breaks. It then takes either that
> adjusted price, or the original price & populate the values into a table.
>
> Select Query:
> SELECT QryBOMDetails2.ParentBOMID, QryBOMDetails2.BOMPrice,
> IIf(IsNull(DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" & [MfrPNID] & "And
> [Level]<=" &
> [ExtQty])),[mfrbaseprice],DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" &
> [MfrPNID] & "And [Level]<=" & [ExtQty])) AS q
> FROM QryBOMDetails2
> WHERE (((QryBOMDetails2.ParentBOMID)=[Forms]![FrmBOMEntry]![TxtBOMID]) AND
> ((QryBOMDetails2.BOMPrice) Is Null));
>
> Update Query:
> UPDATE QryBOMDetails2 SET QryBOMDetails2.BOMPrice =
> IIf(IsNull(DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" & [MfrPNID] & "And
> [Level]<=" &
> [ExtQty])),[mfrbaseprice],DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" &
> [MfrPNID] & "And [Level]<=" & [ExtQty]))
> WHERE (((QryBOMDetails2.BOMPrice) Is Null) AND
> ((QryBOMDetails2.ParentBOMID)=[Forms]![FrmBOMEntry]![TxtBOMID]));
>
> FYI I'm doing this using the query builder.
> Thanks in advance for any advice.
>
>

 
Reply With Quote
 
Jerry Whittle
Guest
Posts: n/a
 
      27th May 2010
I'm very surprised that the query below is updateable when attached to a
form. There's multiple Right and Left Joins and some functions which would
keep those fields from being updated. TblBOMDetails seems to be joined a
bunch of different ways to other tables.

If this complicate query is updateable, then it's just possible that basing
an update query on it is just too much for Access to handle.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"bicyclops" wrote:

> QryBOMDetails2 is a biggie. But it's also attached to a form & normally
> updates with no problem. Sql is below.
>
> SELECT TblBOMDetails.LineItem, TblBOMDetails.BOMDetailID,
> TblBOMDetails.PartNumID, TblBOMDetails.ChildBOMID, [PartPrefix] & "-" &
> Format([Part#Suffix],"0000") AS [ItemPart#], TblBOMDetails.ParentBOMID,
> TblBOMDetails.Qty, TblBOMDetails.OverBuyQty, TblBOMDetails.Refdes,
> TblComps.Description, TblPartPrefix.[Prefix Description],
> TblBOMDetails.MfrPNID, TblMFRPN.MFRPNPart, TblMFR.MFRMfrName,
> TblMFRPN.MFRDesc, TblMFRPN.Price AS MfrBasePrice, TblBOMDetails.VendorPNID,
> TblVendorPN.VendorID, TblVendor.SUSupplier, TblVendorPN.VendorPN,
> TblBOMDetails.CustPNID, TblCompanies.CompanyName, TblCustPN.CustPN,
> TblBOMDetails.SourceFromVendor, TblBOMDetails.VendorSourceQty,
> TblBOMDetails.SourceFromCust, TblBOMDetails.CustSourceQty,
> TblBOMDetails.SourceFromMfr, TblBOMDetails.MfrSourceQty,
> TblBOMDetails.SourceFromStock, TblBOMDetails.StockSourceQty,
> TblComps.StockQty, TblBOM.BuildQty,
> (Nz([BuildQty],1)*[Qty])+(Nz([OverBuyQty],0)) AS ExtQty, TblComps.UnitsID,
> TblUnits.BuyAs, TblBOMDetails.Price AS BOMPrice, TblBOMDetails.MfrPNTemp,
> TblVendor.SUID,
> IIf([ExtQty]<>(Nz([VendorSourceQty],0))+(Nz([CustSourceQty],0))+(Nz([MfrSourceQty],0))+(Nz([StockSourceQty],0)),1,0) AS QtyMismatchFlag
> FROM TblVendor RIGHT JOIN (TblVendorPN RIGHT JOIN (TblUnits RIGHT JOIN
> (TblPartPrefix RIGHT JOIN (TblMFR RIGHT JOIN ((TblCompanies RIGHT JOIN
> TblCustPN ON TblCompanies.CompanyID = TblCustPN.CustID) RIGHT JOIN (TblBOM
> RIGHT JOIN ((TblComps RIGHT JOIN TblBOMDetails ON TblComps.[Part#ID] =
> TblBOMDetails.PartNumID) LEFT JOIN TblMFRPN ON TblBOMDetails.MfrPNID =
> TblMFRPN.MFRPNID) ON TblBOM.BOMID = TblBOMDetails.ParentBOMID) ON
> TblCustPN.CustPNID = TblBOMDetails.CustPNID) ON TblMFR.MFRID =
> TblMFRPN.MFRPNMFRID) ON TblPartPrefix.PartPrefixID = TblComps.PartPrefixID)
> ON TblUnits.ID = TblComps.UnitsID) ON TblVendorPN.VendorPNID =
> TblBOMDetails.VendorPNID) ON TblVendor.SUID = TblVendorPN.VendorID
> ORDER BY TblBOMDetails.LineItem;
>
>
> "Jerry Whittle" wrote:
>
> > > QryBOMDetails2

> >
> > We probably need to see the sql for it. There's many reasons why a query
> > isn't updateable.
> >
> > BTW: Check out my signature line!
> > --
> > Jerry Whittle, Microsoft Access MVP
> > Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
> >
> >
> > "bicyclops" wrote:
> >
> > > The below query works well as a Select Query. But when I turn it into an
> > > update query, I get a whole lot of nothing in the results.
> > >
> > > Interestingly, if I try to call this query from a Macro on my form, I get
> > > error (-20324) repeated the number of times that there are records in the
> > > query.
> > >
> > > It was designed to go into a table of price breaks & decide whether the
> > > quantities being ordered meet the price breaks. It then takes either that
> > > adjusted price, or the original price & populate the values into a table.
> > >
> > > Select Query:
> > > SELECT QryBOMDetails2.ParentBOMID, QryBOMDetails2.BOMPrice,
> > > IIf(IsNull(DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" & [MfrPNID] & "And
> > > [Level]<=" &
> > > [ExtQty])),[mfrbaseprice],DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" &
> > > [MfrPNID] & "And [Level]<=" & [ExtQty])) AS q
> > > FROM QryBOMDetails2
> > > WHERE (((QryBOMDetails2.ParentBOMID)=[Forms]![FrmBOMEntry]![TxtBOMID]) AND
> > > ((QryBOMDetails2.BOMPrice) Is Null));
> > >
> > > Update Query:
> > > UPDATE QryBOMDetails2 SET QryBOMDetails2.BOMPrice =
> > > IIf(IsNull(DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" & [MfrPNID] & "And
> > > [Level]<=" &
> > > [ExtQty])),[mfrbaseprice],DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" &
> > > [MfrPNID] & "And [Level]<=" & [ExtQty]))
> > > WHERE (((QryBOMDetails2.BOMPrice) Is Null) AND
> > > ((QryBOMDetails2.ParentBOMID)=[Forms]![FrmBOMEntry]![TxtBOMID]));
> > >
> > > FYI I'm doing this using the query builder.
> > > Thanks in advance for any advice.
> > >
> > >

 
Reply With Quote
 
bicyclops
Guest
Posts: n/a
 
      27th May 2010
QryBOMDetails2 is a biggie. But it's also attached to a form & normally
updates with no problem. Sql is below.

SELECT TblBOMDetails.LineItem, TblBOMDetails.BOMDetailID,
TblBOMDetails.PartNumID, TblBOMDetails.ChildBOMID, [PartPrefix] & "-" &
Format([Part#Suffix],"0000") AS [ItemPart#], TblBOMDetails.ParentBOMID,
TblBOMDetails.Qty, TblBOMDetails.OverBuyQty, TblBOMDetails.Refdes,
TblComps.Description, TblPartPrefix.[Prefix Description],
TblBOMDetails.MfrPNID, TblMFRPN.MFRPNPart, TblMFR.MFRMfrName,
TblMFRPN.MFRDesc, TblMFRPN.Price AS MfrBasePrice, TblBOMDetails.VendorPNID,
TblVendorPN.VendorID, TblVendor.SUSupplier, TblVendorPN.VendorPN,
TblBOMDetails.CustPNID, TblCompanies.CompanyName, TblCustPN.CustPN,
TblBOMDetails.SourceFromVendor, TblBOMDetails.VendorSourceQty,
TblBOMDetails.SourceFromCust, TblBOMDetails.CustSourceQty,
TblBOMDetails.SourceFromMfr, TblBOMDetails.MfrSourceQty,
TblBOMDetails.SourceFromStock, TblBOMDetails.StockSourceQty,
TblComps.StockQty, TblBOM.BuildQty,
(Nz([BuildQty],1)*[Qty])+(Nz([OverBuyQty],0)) AS ExtQty, TblComps.UnitsID,
TblUnits.BuyAs, TblBOMDetails.Price AS BOMPrice, TblBOMDetails.MfrPNTemp,
TblVendor.SUID,
IIf([ExtQty]<>(Nz([VendorSourceQty],0))+(Nz([CustSourceQty],0))+(Nz([MfrSourceQty],0))+(Nz([StockSourceQty],0)),1,0) AS QtyMismatchFlag
FROM TblVendor RIGHT JOIN (TblVendorPN RIGHT JOIN (TblUnits RIGHT JOIN
(TblPartPrefix RIGHT JOIN (TblMFR RIGHT JOIN ((TblCompanies RIGHT JOIN
TblCustPN ON TblCompanies.CompanyID = TblCustPN.CustID) RIGHT JOIN (TblBOM
RIGHT JOIN ((TblComps RIGHT JOIN TblBOMDetails ON TblComps.[Part#ID] =
TblBOMDetails.PartNumID) LEFT JOIN TblMFRPN ON TblBOMDetails.MfrPNID =
TblMFRPN.MFRPNID) ON TblBOM.BOMID = TblBOMDetails.ParentBOMID) ON
TblCustPN.CustPNID = TblBOMDetails.CustPNID) ON TblMFR.MFRID =
TblMFRPN.MFRPNMFRID) ON TblPartPrefix.PartPrefixID = TblComps.PartPrefixID)
ON TblUnits.ID = TblComps.UnitsID) ON TblVendorPN.VendorPNID =
TblBOMDetails.VendorPNID) ON TblVendor.SUID = TblVendorPN.VendorID
ORDER BY TblBOMDetails.LineItem;


"Jerry Whittle" wrote:

> > QryBOMDetails2

>
> We probably need to see the sql for it. There's many reasons why a query
> isn't updateable.
>
> BTW: Check out my signature line!
> --
> Jerry Whittle, Microsoft Access MVP
> Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
>
>
> "bicyclops" wrote:
>
> > The below query works well as a Select Query. But when I turn it into an
> > update query, I get a whole lot of nothing in the results.
> >
> > Interestingly, if I try to call this query from a Macro on my form, I get
> > error (-20324) repeated the number of times that there are records in the
> > query.
> >
> > It was designed to go into a table of price breaks & decide whether the
> > quantities being ordered meet the price breaks. It then takes either that
> > adjusted price, or the original price & populate the values into a table.
> >
> > Select Query:
> > SELECT QryBOMDetails2.ParentBOMID, QryBOMDetails2.BOMPrice,
> > IIf(IsNull(DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" & [MfrPNID] & "And
> > [Level]<=" &
> > [ExtQty])),[mfrbaseprice],DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" &
> > [MfrPNID] & "And [Level]<=" & [ExtQty])) AS q
> > FROM QryBOMDetails2
> > WHERE (((QryBOMDetails2.ParentBOMID)=[Forms]![FrmBOMEntry]![TxtBOMID]) AND
> > ((QryBOMDetails2.BOMPrice) Is Null));
> >
> > Update Query:
> > UPDATE QryBOMDetails2 SET QryBOMDetails2.BOMPrice =
> > IIf(IsNull(DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" & [MfrPNID] & "And
> > [Level]<=" &
> > [ExtQty])),[mfrbaseprice],DMin("[Price]","TblMfrPriceBreak","[MfrPNID]=" &
> > [MfrPNID] & "And [Level]<=" & [ExtQty]))
> > WHERE (((QryBOMDetails2.BOMPrice) Is Null) AND
> > ((QryBOMDetails2.ParentBOMID)=[Forms]![FrmBOMEntry]![TxtBOMID]));
> >
> > FYI I'm doing this using the query builder.
> > Thanks in advance for any advice.
> >
> >

 
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
update data from aggregate query mbr96 via AccessMonster.com Microsoft Access Queries 4 20th Sep 2007 09:14 PM
Use Aggregate functions in a update query Jose.M.Huerta@gmail.com Microsoft Access Queries 1 21st Apr 2007 05:09 PM
Running an update query based on aggregate result of a select quer =?Utf-8?B?VGltIExvbmc=?= Microsoft Access Queries 4 13th Jul 2005 01:06 AM
How can I set up a combo box to select values in a parameter quer. =?Utf-8?B?V2F5bmU=?= Microsoft Access 1 24th Sep 2004 03:05 PM
Performing an UPDATE query based on an aggregate result Scott Millar Microsoft Access Queries 3 25th Nov 2003 10:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:55 AM.