I have a page that brings up an excel spreadsheet in the browser. The information is coming from a SQL statement. I am having problems getting my number formatting. I have tried different things, but it always comes out crazy. Can someone lead me in the right direction? Thanks.
<%
Response.ContentType = "application/vnd.ms-excel"
%>
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Sales Forecasting Search Results</title>
<%
Dim myConnString
Dim myConnection
Dim mySQL
myConnString = Application("WBW_ConnectionString"
Set myConnection = Server.CreateObject("ADODB.Connection"
myConnection.Open myConnString
mySQL= "SELECT WBW.cust_code, WBW.item_code, Cust_Item.Part_Number, Item.desc1, Item.prod_group, Sum((WBW!inv_qty/WBW!sales_size)*WBW!ut_price) AS [2002 Sales], "
mySQL= mySQL & "Sum(WBW!inv_qty) AS [2002 Qty], Sum(([WBW]![inv_qty2]/[WBW]![sales_size2])*[WBW]![ut_price2]) AS [2003 Sales], Sum([WBW]![inv_qty2]) "
mySQL= mySQL & "AS [2003 Qty] FROM (Item INNER JOIN WBW ON Item.item_code = WBW.item_code) INNER JOIN Cust_Item ON (Cust_Item.cust_code = WBW.cust_code) "
mySQL= mySQL & "AND (WBW.item_code = Cust_Item.item_code) WHERE (((WBW.inv_date)>=#"&Request.Form("inv_date"
&"/2002# And "
mySQL= mySQL & "(WBW.inv_date)<=#"&Request.Form("inv_date2"
&"/2002#)) OR (((WBW.inv_date2)>=#"&Request.Form("inv_date"
&"/2003# And (WBW.inv_date2)<=#"&Request.Form("inv_date2"
&"/2003#)) "
mySQL= mySQL & "GROUP BY WBW.cust_code, WBW.item_code, Cust_Item.Part_Number, Item.desc1, Item.prod_group HAVING (((WBW.cust_code)='"&Request.Form("cust_code"
&"'))"
'response.write mysql
'response.end
set RS=myConnection.execute (mySQL)
'myConnection.Execute mySQL
'Close Connection
%>
<TABLE BORDER=1>
<COL SPAN="1" ALIGN="LEFT"></COL>
<COL SPAN="1" ALIGN="LEFT"></COL>
<COL SPAN="1" ALIGN="LEFT"></COL>
<COL SPAN="1" ALIGN="LEFT"></COL>
<COL SPAN="1" ALIGN="LEFT"></COL>
<COL SPAN="1" ALIGN="RIGHT"></COL>
<COL SPAN="1" ALIGN="RIGHT"></COL>
<COL SPAN="1" ALIGN="RIGHT"></COL>
<COL SPAN="1" ALIGN="RIGHT"></COL>
<TR>
<%
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' % Loop through Fields Names and print out the Field Names
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
j = 2 'row counter
For i = 0 to RS.Fields.Count - 1
%>
<TD><B><% = RS(i).Name %></B> </TD>
<% Next %>
</TR>
<%
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' % Loop through rows, displaying each field
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Do While Not RS.EOF
%>
<TR>
<% For i = 0 to RS.Fields.Count - 1 %>
<TD VALIGN=TOP>
<% RESPONSE.WRITE RS(i).VALUE %> </TD>
<% Next %>
</TR>
<%
RS.MoveNext
j = j + 1
Loop
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' % Make sure to close the Result Set and the Connection object
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
myConnection.Close
Set myConnection = Nothing
%>
Thanks!
<%
Response.ContentType = "application/vnd.ms-excel"
%>
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Sales Forecasting Search Results</title>
<%
Dim myConnString
Dim myConnection
Dim mySQL
myConnString = Application("WBW_ConnectionString"
Set myConnection = Server.CreateObject("ADODB.Connection"
myConnection.Open myConnString
mySQL= "SELECT WBW.cust_code, WBW.item_code, Cust_Item.Part_Number, Item.desc1, Item.prod_group, Sum((WBW!inv_qty/WBW!sales_size)*WBW!ut_price) AS [2002 Sales], "
mySQL= mySQL & "Sum(WBW!inv_qty) AS [2002 Qty], Sum(([WBW]![inv_qty2]/[WBW]![sales_size2])*[WBW]![ut_price2]) AS [2003 Sales], Sum([WBW]![inv_qty2]) "
mySQL= mySQL & "AS [2003 Qty] FROM (Item INNER JOIN WBW ON Item.item_code = WBW.item_code) INNER JOIN Cust_Item ON (Cust_Item.cust_code = WBW.cust_code) "
mySQL= mySQL & "AND (WBW.item_code = Cust_Item.item_code) WHERE (((WBW.inv_date)>=#"&Request.Form("inv_date"
mySQL= mySQL & "(WBW.inv_date)<=#"&Request.Form("inv_date2"
mySQL= mySQL & "GROUP BY WBW.cust_code, WBW.item_code, Cust_Item.Part_Number, Item.desc1, Item.prod_group HAVING (((WBW.cust_code)='"&Request.Form("cust_code"
'response.write mysql
'response.end
set RS=myConnection.execute (mySQL)
'myConnection.Execute mySQL
'Close Connection
%>
<TABLE BORDER=1>
<COL SPAN="1" ALIGN="LEFT"></COL>
<COL SPAN="1" ALIGN="LEFT"></COL>
<COL SPAN="1" ALIGN="LEFT"></COL>
<COL SPAN="1" ALIGN="LEFT"></COL>
<COL SPAN="1" ALIGN="LEFT"></COL>
<COL SPAN="1" ALIGN="RIGHT"></COL>
<COL SPAN="1" ALIGN="RIGHT"></COL>
<COL SPAN="1" ALIGN="RIGHT"></COL>
<COL SPAN="1" ALIGN="RIGHT"></COL>
<TR>
<%
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' % Loop through Fields Names and print out the Field Names
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
j = 2 'row counter
For i = 0 to RS.Fields.Count - 1
%>
<TD><B><% = RS(i).Name %></B> </TD>
<% Next %>
</TR>
<%
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' % Loop through rows, displaying each field
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Do While Not RS.EOF
%>
<TR>
<% For i = 0 to RS.Fields.Count - 1 %>
<TD VALIGN=TOP>
<% RESPONSE.WRITE RS(i).VALUE %> </TD>
<% Next %>
</TR>
<%
RS.MoveNext
j = j + 1
Loop
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' % Make sure to close the Result Set and the Connection object
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
myConnection.Close
Set myConnection = Nothing
%>
Thanks!