Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access ASP
|
Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 15th, 2006, 09:33 AM
Registered User
 
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem querying access, exporting to Excel

I'm query an access database, which is working fine displaying as web content. I would like to export the results to excel. I have the code below, which does not give errors, but produces an empty exel file. :( Any ideas?


<%@ Language=VBScript %>
<%
dim Cn,Rs
set Cn=server.createobject("ADODB.connection")
set Rs=server.createobject("ADODB.recordset")

Cn.open "provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("sheep.mdb")
Rs.open "SELECT * FROM tblInfo WHERE Name = '" & request("name") & "' OR Description = '" & request("description") & "' OR Location = '" & request("location") & "' ", Cn

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=Enquiry_List.xls"
response.write "<table border=1>"
do while not Rs.eof
response.write "<tr><td nowrap> " & Rs.fields("Name") & "</td><td nowrap>" & Rs.fields("Description") & "</td><td nowrap>" & Rs.fields("Location") & "</td></tr>"
Rs.movenext
loop
response.write "</table>"

set Rs=nothing
Cn.close
%>
 
Old November 22nd, 2006, 12:54 AM
Authorized User
 
Join Date: Nov 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

try using the open document event as a excel macro:

open excel > goto tools / macro / vb editor > click on this workbook and on the top left combo click workbook and on the top right click open you should have this:

Private Sub Workbook_Open()
   Stop
End Sub

...where it says stop type in the code, i tested it and it hit stop right away when i opened it. All you have to do then is open the file from access, the code will trigger even if opened from access. Save the file as a template, just an idea.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting From Access To Excel jimnich Access VBA 17 February 8th, 2008 07:23 AM
Exporting to Existing Excel Worksheet from Access kfs Access VBA 2 August 3rd, 2006 10:56 AM
Exporting to Excel from Access - field headings no chimp Access VBA 1 July 9th, 2004 11:54 AM
exporting a workbook from excel to access zisko3 Access 1 February 3rd, 2004 12:05 PM
Exporting access database to Excel .xls Squall Leonhart Classic ASP Databases 5 December 2nd, 2003 07:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.