473,320 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

group total in a report

Hello,

I have a table(msaccess) with the structure...
job_code text 6
style text 10
qty number
fabrication text 65
ship_date date/time
I want to show a report like...

job_code style qty fabrication ship_date
------------------------------------------------------
05A001 2464 75000 AAAAAAA 5-Jan-2005
05A002 3800 93430 BBBBBBB 5-Jan-2005
05B001 2845 4900 CCCCCCC 5-Jan-2005

----------
173330
05A003 2564 45000 DDDDDDD 5-Feb-2005
05B002 2800 65000 EEEEEEE 15-Feb-2005
05C001 P357G 5500 FFFFFFF 15-Feb-2005
------------
115500

.....

What could be the query and how can i show an HTML report. I am using ADO
with ASP and VBScript.
thanx in advance

Jul 22 '05 #1
1 1981
Rajani wrote:
Hello,

I have a table(msaccess) with the structure...
job_code text 6
style text 10
qty number
fabrication text 65
ship_date date/time
I want to show a report like...

job_code style qty fabrication ship_date
------------------------------------------------------
05A001 2464 75000 AAAAAAA 5-Jan-2005
05A002 3800 93430 BBBBBBB 5-Jan-2005
05B001 2845 4900 CCCCCCC 5-Jan-2005

----------
173330
05A003 2564 45000 DDDDDDD 5-Feb-2005
05B002 2800 65000 EEEEEEE 15-Feb-2005
05C001 P357G 5500 FFFFFFF 15-Feb-2005
------------
115500

....

What could be the query and how can i show an HTML report. I am using
ADO with ASP and VBScript.
thanx in advance


You can use a UNION query inside a subquery for this:

Select job_code, style, qty, fabrication,
ship_date FROM
(
Select 'Detail' As RowType, job_code, style, qty, fabrication,
ship_date, Year(ship_date) As ShipYear,
Month(ship_date) As ShipMonth
FROM Shipments
UNION ALL
Select 'Total' As RowType,'Total','',Sum(qty),'',Null,Year(ship_date ),
Month(ship_date)
FROM Shipments
GROUP BY Year(ship_date),Month(ship_date)
) As q
ORDER BY ShipYear, ShipMonth, RowType, ship_date

I would create a saved query with this SQL and save it as qShipmentReport.
If you need to limit the time period used for the report, then you can add
parameters, like this:

Select job_code, style, qty, fabrication,
ship_date FROM
(
Select 'Detail' As RowType, job_code, style, qty, fabrication,
ship_date, Year(ship_date) As ShipYear,
Month(ship_date) As ShipMonth
FROM Shipments
WHERE ship_date BETWEEN [pStart] AND [pYear]
UNION ALL
Select 'Total' As RowType,'Total','',Sum(qty),'',Null,
Year(ship_date),Month(ship_date)
FROM Shipments
WHERE ship_date BETWEEN [pStart] AND [pYear]
GROUP BY Year(ship_date),Month(ship_date)
) As q
ORDER BY ShipYear, ShipMonth, RowType, ship_date
The ASP code to display the report would look like this (tested in IE6 - you
may need to tweak it for other browsers. If so, follow up in a client-side
newsgroup):

<%@ Language=VBScript %>
<%
dim sHTML, dStart, dEnd, cn, rs, arData, sCellTagSt, sCellTagEnd
dim iRow, iCol
dStart=Request.Form("StartDate")
dEnd=Request.Form("EndDate")
if len(dStart) > 0 AND len(dEnd)>0 Then
if IsDate(dStart) AND IsDate(dEnd) then
dStart=cdate(dStart)
dEnd=cdate(dEnd)
Set cn=CreateObject("adodb.connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=P:\ath\to\database.mdb"
set rs=CreateObject("adodb.recordset")
cn.qShipmentReport dStart,dEnd, rs
if not rs.EOF then arData=rs.GetRows
rs.Close:set rs=nothing
cn.Close:set cn=nothing
if IsArray(arData) then
for iRow = 0 to UBound(arData,2)
if len(sHTML) = 0 then
sHTML= "<TR>"
else
sHTML=sHTML & "<TR>"
end if
if arData(0,iRow)="Total" then
sCellTagSt="<TH>"
sCellTagEnd="</TH>"
else
sCellTagSt="<TD>"
sCellTagEnd="</TD>"
end if
for iCol=0 to UBound(arData,1)
sHTML=sHTML & sCellTagSt & arData(iCol,iRow) & _
sCellTagEnd
next
sHTML=sHTML & "</TR>"
next
else
sHTML="<tr><td colspan=5>No data was found in this " & _
"date range</td></tr>"
end if
else
sHTML="<tr><td colspan=5>Invalid Date Entered." & _
"Date must be in YYYY-MM-DD format. Ex. 2004-12-01</td></tr>"
end if
End if
%>
<HTML>
<HEAD>
<TITLE>Shipment Report</TITLE>
</HEAD>
<BODY>
<H1>Shipment Report</H1>
<form method="post">
<span
style="margin-right:20px;font: normal normal bold x-small Arial">
Start Date (YYYY-MM-DD): <input name="StartDate"
value="<%=Request.Form("StartDate")%>">
</span>
<span style="font: normal normal bold x-small Arial">
End Date (YYYY-MM-DD): <input name="EndDate"
value="<%=Request.Form("EndDate")%>">
</span>
<input type="submit" value="Submit">
<input type="button" value="Clear"
onclick="document.getElementById('StartDate').valu e='';
document.getElementById('EndDate').value='';
document.forms(0).submit()">
</form>
<table border="1"
style="border-color:black;border-collapse:collapse">
<TR style="background-color:lightblue">
<TH>Job Code</TH>
<TH>Style</TH>
<TH>Quantity</TH>
<TH>Fabrication</TH>
<TH>Ship Date</TH>
</TR>
<%=sHTML%>
</table>
</BODY>
</HTML>

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Galina | last post by:
Hello I have a report, which lists records. Each record has money paid field. Money paid can be 0 or not 0. I calculate and print summary of money for a group in the group footer, as well as...
2
by: Pea | last post by:
Hello, I have a report with groups, subgroups and counts. I'm trying to give a total for each group and used the RunningSum property by group. But I find that it's running throughout the report....
3
by: Pecanfan | last post by:
Hi, I've got an access report which contains a sub-report. The sub-report contains various items in a group Footer which culminates in a running sum text box called txtGrandTotal. I want to...
7
by: Darin | last post by:
I have a report that sub-totals on a group, then grand-totals at the report footer. If there's only one group, the sub-total and grand total are redundant, so I only want to show one of them. I...
0
by: willemp | last post by:
i have a report with a 3 groups in it A - project B - person each record in the report consists of a single realised workday on a single project by a single person. so i have records that...
0
by: willemp | last post by:
i have a report with a 3 groups in it A - project B - person each record in the report consists of a single realised workday on a single project by a single person.
7
by: Sunil Korah | last post by:
Hi, I haven't used access reports much. I have a problem in getting the total of a group. I have 3 fields, ProgName (Program name), Pname (Participant's name) and PCategory (Participant...
15
klarae99
by: klarae99 | last post by:
I am working on an Inventory Database in Access 2003. I am working on a report that I could print when its time to file our State Sales Tax paperwork. The figures I need for this report are Total...
2
by: hanshirley88 | last post by:
Hi, I am doing an expense and funding report which contains a list of consumers by Region and then by SiteID. For example, Region: NE Site: NEMV 1. Mary Doe 2. Len Willams
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.