G
Guest
I have a report that is generated based on criteria chosen in a multi-select
list box form. I’m trying to summarize the form by displaying currency
totals on the form, but one field/control is not calculating accurate totals.
Here is how the form is structured:
The report returns only one “ProjectNameâ€, which is accounted for in the
report header.
Under that, there can be more than one “BidNumberâ€, based on what is
selected in the multi-select list box. The data related to this is grouped
together, and within the “Bid†table is a field called “SalesTaxAmountâ€.
Under that is the “ItemLabel†portion of the report, which contains the
detail.
The SalesTaxAmount field in the Bid table contains a fixed currency amount
that users enter, so there is only one value per BidNumber. I created a
control in the report named SalesTaxTotal, which is intended to add the
SalesTaxAmount for BidNumber 01, 02, 03, etc. In the control source I have
the expression: =Sum([SalesTaxAmount]). The problem I’m having is that it
is adding one SalesTaxAmount value for each record in the detail. For
example, if the value in SalesTaxAmount is $100.00, and there are 20 records,
the control SalesTaxTotal returns $2,000.00.
I suspect it may have something to do with the code in the multi-select list
box form, so I have pasted a portion that at the end of this post. I’m no VB
expert, but noticed that “Bid.SalesTaxAmount†exists in a couple locations.
Any help with this would be greatly appreciated! Thanks!
Here is that code:
strSQL = "SELECT Project.ProjectName, Bid.BidNumber, Item.RoomNumber & "" -
"" & Item.ItemNumber AS ItemLabel, Item.RoomNumber, Item.ItemNumber,
Product.LibraryReference, Item.RoomName, Item.ElevationReference,
Item.ProductSummary, ItemDetail.Quantity, ItemDetail.ProductDescription,
Product.UnitCost, ItemDetail.QuoteCost, Product.UOM,
[Quantity]*([UnitCost]+[QuoteCost]) AS LineTotalCost, ItemDetail.Markup,
[LineTotalCost]*[Markup] AS SellPrice, Project.SalesTax, Bid.[Engineering%],
Bid.SalesTaxAmount, Bid.BidDate, Bid.Estimator, Project.GCName,
ItemDetail.ItemDetailNotes, Bid.SalesTaxAmount, Project.GCContact,
Bid.PriceIncludes, Bid.PriceDoesNotInclude, Customer.GCStreetAddress,
[GCCity] & "" , "" & [GCState] & "" "" & [GCZip] AS CityState,
Bid.ScopeNotes, Bid.BidType" & _
" FROM (Labor INNER JOIN Product ON Labor.CBDCode = Product.CBDCode) INNER
JOIN (Bid INNER JOIN (Customer INNER JOIN ((ItemDetail INNER JOIN Project ON
ItemDetail.ProjectName = Project.ProjectName) INNER JOIN Item ON
(Item.ItemNumber = ItemDetail.ItemNumber) AND (Item.RoomNumber =
ItemDetail.RoomNumber) AND (Item.BidNumber = ItemDetail.BidNumber) AND
(Item.ProjectName = ItemDetail.ProjectName) AND (Project.ProjectName =
Item.ProjectName)) ON (Customer.GCName = Project.GCName) AND (Customer.GCName
= Project.GCName)) ON (Project.ProjectName = Bid.ProjectName) AND
(Bid.BidNumber = Item.BidNumber) AND (Bid.ProjectName = Item.ProjectName)) ON
Product.ProductDescription = ItemDetail.ProductDescription" & _
" WHERE Project.ProjectName = '" & Me.cboProjectName & "' And
(Bid.BidNumber) in (" & strCriteria & ")" & _
" ORDER BY Project.ProjectName, Bid.BidNumber, Item.RoomNumber & "" - "" &
Item.ItemNumber, Item.RoomNumber, Item.ItemNumber, Product.LibraryReference,
Product.ProductCode;"
list box form. I’m trying to summarize the form by displaying currency
totals on the form, but one field/control is not calculating accurate totals.
Here is how the form is structured:
The report returns only one “ProjectNameâ€, which is accounted for in the
report header.
Under that, there can be more than one “BidNumberâ€, based on what is
selected in the multi-select list box. The data related to this is grouped
together, and within the “Bid†table is a field called “SalesTaxAmountâ€.
Under that is the “ItemLabel†portion of the report, which contains the
detail.
The SalesTaxAmount field in the Bid table contains a fixed currency amount
that users enter, so there is only one value per BidNumber. I created a
control in the report named SalesTaxTotal, which is intended to add the
SalesTaxAmount for BidNumber 01, 02, 03, etc. In the control source I have
the expression: =Sum([SalesTaxAmount]). The problem I’m having is that it
is adding one SalesTaxAmount value for each record in the detail. For
example, if the value in SalesTaxAmount is $100.00, and there are 20 records,
the control SalesTaxTotal returns $2,000.00.
I suspect it may have something to do with the code in the multi-select list
box form, so I have pasted a portion that at the end of this post. I’m no VB
expert, but noticed that “Bid.SalesTaxAmount†exists in a couple locations.
Any help with this would be greatly appreciated! Thanks!
Here is that code:
strSQL = "SELECT Project.ProjectName, Bid.BidNumber, Item.RoomNumber & "" -
"" & Item.ItemNumber AS ItemLabel, Item.RoomNumber, Item.ItemNumber,
Product.LibraryReference, Item.RoomName, Item.ElevationReference,
Item.ProductSummary, ItemDetail.Quantity, ItemDetail.ProductDescription,
Product.UnitCost, ItemDetail.QuoteCost, Product.UOM,
[Quantity]*([UnitCost]+[QuoteCost]) AS LineTotalCost, ItemDetail.Markup,
[LineTotalCost]*[Markup] AS SellPrice, Project.SalesTax, Bid.[Engineering%],
Bid.SalesTaxAmount, Bid.BidDate, Bid.Estimator, Project.GCName,
ItemDetail.ItemDetailNotes, Bid.SalesTaxAmount, Project.GCContact,
Bid.PriceIncludes, Bid.PriceDoesNotInclude, Customer.GCStreetAddress,
[GCCity] & "" , "" & [GCState] & "" "" & [GCZip] AS CityState,
Bid.ScopeNotes, Bid.BidType" & _
" FROM (Labor INNER JOIN Product ON Labor.CBDCode = Product.CBDCode) INNER
JOIN (Bid INNER JOIN (Customer INNER JOIN ((ItemDetail INNER JOIN Project ON
ItemDetail.ProjectName = Project.ProjectName) INNER JOIN Item ON
(Item.ItemNumber = ItemDetail.ItemNumber) AND (Item.RoomNumber =
ItemDetail.RoomNumber) AND (Item.BidNumber = ItemDetail.BidNumber) AND
(Item.ProjectName = ItemDetail.ProjectName) AND (Project.ProjectName =
Item.ProjectName)) ON (Customer.GCName = Project.GCName) AND (Customer.GCName
= Project.GCName)) ON (Project.ProjectName = Bid.ProjectName) AND
(Bid.BidNumber = Item.BidNumber) AND (Bid.ProjectName = Item.ProjectName)) ON
Product.ProductDescription = ItemDetail.ProductDescription" & _
" WHERE Project.ProjectName = '" & Me.cboProjectName & "' And
(Bid.BidNumber) in (" & strCriteria & ")" & _
" ORDER BY Project.ProjectName, Bid.BidNumber, Item.RoomNumber & "" - "" &
Item.ItemNumber, Item.RoomNumber, Item.ItemNumber, Product.LibraryReference,
Product.ProductCode;"