473,781 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2014
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_dat e)
) 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_dat e)
FROM Shipments
WHERE ship_date BETWEEN [pStart] AND [pYear]
GROUP BY Year(ship_date) ,Month(ship_dat e)
) 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=VBScri pt %>
<%
dim sHTML, dStart, dEnd, cn, rs, arData, sCellTagSt, sCellTagEnd
dim iRow, iCol
dStart=Request. Form("StartDate ")
dEnd=Request.Fo rm("EndDate")
if len(dStart) > 0 AND len(dEnd)>0 Then
if IsDate(dStart) AND IsDate(dEnd) then
dStart=cdate(dS tart)
dEnd=cdate(dEnd )
Set cn=CreateObject ("adodb.connect ion")
cn.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=P:\ath\t o\database.mdb"
set rs=CreateObject ("adodb.records et")
cn.qShipmentRep ort dStart,dEnd, rs
if not rs.EOF then arData=rs.GetRo ws
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,iRo w) & _
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>Inval id Date Entered." & _
"Date must be in YYYY-MM-DD format. Ex. 2004-12-01</td></tr>"
end if
End if
%>
<HTML>
<HEAD>
<TITLE>Shipme nt 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="<%=Reque st.Form("StartD ate")%>">
</span>
<span style="font: normal normal bold x-small Arial">
End Date (YYYY-MM-DD): <input name="EndDate"
value="<%=Reque st.Form("EndDat e")%>">
</span>
<input type="submit" value="Submit">
<input type="button" value="Clear"
onclick="docume nt.getElementBy Id('StartDate') .value='';
document.getEle mentById('EndDa te').value='';
document.forms( 0).submit()">
</form>
<table border="1"
style="border-color:black;bor der-collapse:collap se">
<TR style="backgrou nd-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
7156
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 summary of money for all groups the report footer. When there is at least one record with money >0, group and report footers are appropriate and look OK. When all records are with 0 money, footers look silly. I’d like not to print them. I have placed...
2
1643
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. Is there a way to reset this ? Here's an example: June 2004 John Doe 6/18/04 ABC Transaction 6 6/22/04 XYZ Transaction 2
3
5150
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 use this 'total' in the main report so I have a text box with the following:- =(!!.!) For some reason, which I'm sure is perfectly obvious but I'm buggered if I
7
4543
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 know how to count the groups, then hide the report footer if there's only one group, but my problem is I want to hide the group footer (sub-total), not the report footer (because the report footer references what the grand total is for, which is...
0
1361
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 contain projectname,personname,date,worked hours, and the hours that where planned for this person on this project
0
2357
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
3657
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 category) PCategory can have values 'SC', 'ST' and 'Others'
15
6179
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 Sales(not including tax), the Amount of Sales Subject to Tax, and the Total Sales Including Tax, all gathered for a specific time period. I have a query (qrySalesTax) to find all sales within a specified date range that also calculates the Total...
2
1986
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
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10143
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5507
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4040
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.