M
Michael
I know the subject line is confusing, that is because I am confused
I have one query the calculates the sum of plastic used in packageing an
order and the amount of trays. (see below consumenew query) and another
query to total the amounts used by container size. (see below
consumenewtotal query)
From the consumenewtotal I have made a report (consumenewtotal) that I want
to be able to search by date range and have made a calendar form with the
following code. (See calendar code).
The problem is that if I include the orderdate in the consumenewtotal query,
then when I get my list is shows a total for each day for each product
listed separately.
example
Confezione Vaschetta total
b2680 704 109120 01/11/2005
b2680 704 218240 01/11/2005
without the date I get the numbers I require as
b2680 1408 327360
How can I search by date and not have it separate the items by date?
Michael
consumenew query
SELECT [order details query].OrderID, [order details query].[Colli x
Pedana], [order details query].[N° Pedane], [order details query].confezione
AS [order details query_confezione], [order details query].confezione,
Consume.Film, Consume.Lung, Consume.desc, [Colli x Pedana]*[N°
Pedane]*[film]*[Lung]*[consume.desc]/1000 AS [consume film], [order details
query].orderdate
FROM [order details query] INNER JOIN Consume ON [order details
query].confezione = Consume.Confezione
GROUP BY [order details query].OrderID, [order details query].[Colli x
Pedana], [order details query].[N° Pedane], [order details
query].confezione, [order details query].confezione, Consume.Film,
Consume.Lung, Consume.desc, [Colli x Pedana]*[N°
Pedane]*[film]*[Lung]*[consume.desc]/1000, [order details query].orderdate;
consumenewtotals
SELECT Sum(([colli x Pedana]*[desc])) AS vas, consumenew.confezione,
Sum(consumenew.[consume film]) AS [SumOfconsume film], consumenew.orderdate
FROM consumenew
GROUP BY consumenew.confezione, consumenew.orderdate;
calendar code
Private Sub ok_Click()
Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for OpenReport.
Const conDateFormat = "\#mm\/dd\/yyyy\#"
strReport = "consumenewtotal"
strField = "[OrderDate]"
If IsNull(Me.txtStartDate) Then
If Not IsNull(Me.txtEndDate) Then 'End date, but no start.
strWhere = strField & " < " & Format(Me.txtEndDate,
conDateFormat)
End If
Else
If IsNull(Me.txtEndDate) Then 'Start date, but no End.
strWhere = strField & " > " & Format(Me.txtStartDate,
conDateFormat)
Else 'Both start and end dates.
strWhere = strField & " Between " & Format(Me.txtStartDate,
conDateFormat) _
& " And " & Format(Me.txtEndDate, conDateFormat)
End If
End If
' Debug.Print strWhere 'For debugging purposes only.
DoCmd.OpenReport strReport, acViewPreview, , strWhere
End Sub
I have one query the calculates the sum of plastic used in packageing an
order and the amount of trays. (see below consumenew query) and another
query to total the amounts used by container size. (see below
consumenewtotal query)
From the consumenewtotal I have made a report (consumenewtotal) that I want
to be able to search by date range and have made a calendar form with the
following code. (See calendar code).
The problem is that if I include the orderdate in the consumenewtotal query,
then when I get my list is shows a total for each day for each product
listed separately.
example
Confezione Vaschetta total
b2680 704 109120 01/11/2005
b2680 704 218240 01/11/2005
without the date I get the numbers I require as
b2680 1408 327360
How can I search by date and not have it separate the items by date?
Michael
consumenew query
SELECT [order details query].OrderID, [order details query].[Colli x
Pedana], [order details query].[N° Pedane], [order details query].confezione
AS [order details query_confezione], [order details query].confezione,
Consume.Film, Consume.Lung, Consume.desc, [Colli x Pedana]*[N°
Pedane]*[film]*[Lung]*[consume.desc]/1000 AS [consume film], [order details
query].orderdate
FROM [order details query] INNER JOIN Consume ON [order details
query].confezione = Consume.Confezione
GROUP BY [order details query].OrderID, [order details query].[Colli x
Pedana], [order details query].[N° Pedane], [order details
query].confezione, [order details query].confezione, Consume.Film,
Consume.Lung, Consume.desc, [Colli x Pedana]*[N°
Pedane]*[film]*[Lung]*[consume.desc]/1000, [order details query].orderdate;
consumenewtotals
SELECT Sum(([colli x Pedana]*[desc])) AS vas, consumenew.confezione,
Sum(consumenew.[consume film]) AS [SumOfconsume film], consumenew.orderdate
FROM consumenew
GROUP BY consumenew.confezione, consumenew.orderdate;
calendar code
Private Sub ok_Click()
Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for OpenReport.
Const conDateFormat = "\#mm\/dd\/yyyy\#"
strReport = "consumenewtotal"
strField = "[OrderDate]"
If IsNull(Me.txtStartDate) Then
If Not IsNull(Me.txtEndDate) Then 'End date, but no start.
strWhere = strField & " < " & Format(Me.txtEndDate,
conDateFormat)
End If
Else
If IsNull(Me.txtEndDate) Then 'Start date, but no End.
strWhere = strField & " > " & Format(Me.txtStartDate,
conDateFormat)
Else 'Both start and end dates.
strWhere = strField & " Between " & Format(Me.txtStartDate,
conDateFormat) _
& " And " & Format(Me.txtEndDate, conDateFormat)
End If
End If
' Debug.Print strWhere 'For debugging purposes only.
DoCmd.OpenReport strReport, acViewPreview, , strWhere
End Sub