If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > calling Access Report from ASP

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-02-04, 15:05
SuNG SuNG is offline
Registered User
 
Join Date: Apr 2004
Posts: 13
calling Access Report from ASP

Hi guys,
I am trying to use ASP (vbscript) to bring out Access genereated reports dynamically. The query for the report works fine since the report runs perfectly in Access.
query looks somethin like this..
Code:
 sSQL = " SELECT weekendingEmp.WeekEnding, " & _
	" weekendingEmp.EmployeeID, " & _
	" Employees.EmployeeName, " & _
	" Sum(Hours.Hours) AS SumOfHours, " & _
	" Employees.BaseWeekHours, " & _
	" Employees.Current " & _
	" FROM (weekendingEmp LEFT JOIN Hours ON (weekendingEmp.EmployeeID = Hours.EmployeeID) " & _
	" AND (weekendingEmp.WeekEnding = Hours.WeekEnding)) " & _
	" INNER JOIN Employees ON weekendingEmp.EmployeeID = Employees.EmployeeID " & _
	" GROUP BY weekendingEmp.WeekEnding, " & _
	" weekendingEmp.EmployeeID, " & _
	" Employees.EmployeeName, " & _
	" Employees.BaseWeekHours, " & _
	" Employees.Current "& _
	" HAVING ((..some condition..) AND (Sum(Hours.Hours)<[BaseWeekHours]) AND ((Employees.Current) = True)) " & _
	" ORDER BY weekendingEmp.WeekEnding DESC; "
Interesting thing is, if i take out (Employees.Current = True) statement, i can actually see the report on my asp page..
but if i keep that statment, i get: "HTTP 404 - File not found" error.. i want to keep that statement because the report is only interested in employees who are currently employeed..
anybody know wut's wrong?
any help will be greatly appreciated..
thanks

Last edited by SuNG; 04-02-04 at 15:08.
Reply With Quote
  #2 (permalink)  
Old 04-02-04, 16:51
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Try replacing true with On or 1. Access has some fields that don't map very well to standard data types using ado/oledb/odbc
Reply With Quote
  #3 (permalink)  
Old 04-02-04, 17:16
SuNG SuNG is offline
Registered User
 
Join Date: Apr 2004
Posts: 13
hey thanks for the fast reply.. but that doesn't work either..
Reply With Quote
  #4 (permalink)  
Old 04-04-04, 19:55
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
I can't help but wonder if the problem lies somewhere else. Do you want to include the entire page script??
Reply With Quote
  #5 (permalink)  
Old 04-05-04, 10:21
SuNG SuNG is offline
Registered User
 
Join Date: Apr 2004
Posts: 13
sure.. i hope this can help..

Code:
 Dim sRpt, sPath, sXML, sXSL, sRedirectTo
  Dim sMDB, sAppName, objAcc, objQry, sQry, sSQL
  Dim dteStart, dteEnd, sFormat, iFrmt, sMsg
   
  Const fmtASP = 4
  Const fmtHTM = 0
  Const acExpRpt = 3
  Const acUTF8 = 0
  
  ' Set the name of the Access XP report and fmt file
  sRpt = Request("Report")
  ' If missing, run Report
  If sRpt = "" Then sRpt = "Report"

  sFormat = Request("Format")
  If sFormat = "" Then sFormat = "asp"

  ' Assume that Access XP database file is in the same 
  ' web folder as the ASP page.  Determine the path 
  ' and use it to set the XML and XSL file names.
  sMDB = Server.MapPath("/test/Time_Track2002.mdb")
  Response.Write "Database: '" & sMDB & "'"
  ' Response.End
  sPath = Left(sMDB, Len(sMDB) - Len("Time_Track2002.mdb"))
  sXML = sPath & sRpt & ".xml"
  sXSL = sPath & sRpt & ".xsl"
    
  ' Create Access XP Application Object and open it.
  sAppName = "Access.Application.10"
  Set objAcc = Server.CreateObject(sAppName)
  objAcc.OpenCurrentDatabase sMDB

 sSQL = " SELECT weekendingEmp.WeekEnding, " & _
	" weekendingEmp.EmployeeID, " & _
	" Employees.EmployeeName, " & _
	" Sum(Hours.Hours) AS SumOfHours, " & _
	" Employees.BaseWeekHours, " & _
	" Employees.Current " & _
	" FROM (weekendingEmp LEFT JOIN Hours ON (weekendingEmp.EmployeeID = Hours.EmployeeID) " & _
	" AND (weekendingEmp.WeekEnding = Hours.WeekEnding)) " & _
	" INNER JOIN Employees ON weekendingEmp.EmployeeID = Employees.EmployeeID " & _
	" GROUP BY weekendingEmp.WeekEnding, " & _
	" weekendingEmp.EmployeeID, " & _
	" Employees.EmployeeName, " & _
	" Employees.BaseWeekHours, " & _
	" Employees.Current "& _
	" HAVING (((weekendingEmp.WeekEnding)>DateAdd(""ww"",-30,Now())) AND ((Sum(Hours.Hours))<[BaseWeekHours] Or (Sum(Hours.Hours)) Is Null) AND ((Employees.Current) = On)) " & _
	" ORDER BY weekendingEmp.WeekEnding DESC; " 
         
  sQry = "TimesheetQryIntranet"
  
  Set objQry = objAcc.DBEngine(0)(0).QueryDefs(sQry)
  objQry.SQL = sSQL
  Set objQry = Nothing
  
    sRedirectTo = sRpt & ".asp"
    iFrmt = fmtASP

  objAcc.ExportXML acExpRpt,sRpt,sXML,,sXSL,,,iFrmt
  
  objAcc.CloseCurrentDatabase
  objAcc.Quit
  Set objAcc = Nothing

  Response.Redirect sRedirectTo
Reply With Quote
  #6 (permalink)  
Old 04-05-04, 11:20
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
so have you checked sRedirectTo to ensure you are always redirecting to the right location??
Reply With Quote
  #7 (permalink)  
Old 04-05-04, 11:26
SuNG SuNG is offline
Registered User
 
Join Date: Apr 2004
Posts: 13
yea... it works fine..
since if i just take that "Employees.Current = True" Statement out, everything works perfectly..
Reply With Quote
  #8 (permalink)  
Old 04-05-04, 11:33
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Having a bit more detailed read of the code I can see what you are doing now and it makes a bit more sense...

Basically your 404 is because there are no results returned to export and thus no page is created....

I'm not sure why it is not returning any data when you remove that where clause though. All I could suggest is possibly changing it to 'True' or true or some other variation.

You might want to make another post with a different title and seem is you get a better response... something like checking true/false columns in Access.
Reply With Quote
  #9 (permalink)  
Old 04-05-04, 12:21
SuNG SuNG is offline
Registered User
 
Join Date: Apr 2004
Posts: 13
coo.. thanks for ur help
Reply With Quote
  #10 (permalink)  
Old 04-06-04, 13:02
SuNG SuNG is offline
Registered User
 
Join Date: Apr 2004
Posts: 13
Hey sup,

i figured out wut the problem was... u see.. it didn't like "Current" field name because "Current" is actually a key name and is a function...
so after putting square brackets.. like: [Current] solved the problem..
Reply With Quote
  #11 (permalink)  
Old 04-06-04, 18:50
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
errghhhh,... yeah, that would make sense.... glad to hear your found the problem.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On