473,473 Members | 2,155 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Access Reports using ASP

Hi people,

I know that the question has come around sometimes:
How to open an Access Report using ASP and export it to for example
RTF.

I'm trying to implement the first method of David Cline:

http://www.15seconds.com/issue/981216.htm

The first section describes how it should be done, and it sounds good
to me.

Way of working:

1. open Access object
2. open the needed database
3. open the report fromthe database
4. open the query that belongs to the report
5. fill the parameters from the query from a HTML form, if the params
are not filled, display the HTML form
6. execute the query with params, so the report gives the correct data
7. export the report to RTF format

every step works in this process, except step 6. Dave Cline's example
states a:
qry.execute

then I get an:
Error Type:
DAO.QueryDef (0x800A0BF9)
Cannot execute a select query.

This is quite logical, because the query is a select query.

If I leave out step 6, I get dialog popupboxes where I need to fill in
the parameters for the query, and I don't want that.

Anyone have an idea what I should change?
(I know this isn't the most nicest solution for the server, but it's
only for inhouse use)

some code snippets:

strReportName = "frmPOST_DATUM"
blnRunReport = True

'--- create an instance of Access --
set mobjAccess = createobject("access.application.11")
mobjAccess.OpenCurrentDatabase
"C:\Inetpub\wwwroot\kempen\database\post.mdb"
mobjAccess.Visible = False

'--- the DoCmd object is the easiest way to open a report --
Set MyDoCmd = mobjAccess.DoCmd
MyDoCmd.OpenReport strReportName, 1 '1=design, 0=normal, 2=preview

'--- create a reference to the now open report --
Set rpt = mobjAccess.Reports(0)

'--- Open the Query the report is based upon –
Set qry = mobjAccess.CurrentDb.QueryDefs("qryPOST_REPORT_DAT UM")

'--- loop through the queries parameters --
If qry.Parameters.Count > 0 then
Response.write "<form action=""report.asp"" method=""post"">"

For Each param In qry.Parameters

'--- to print the report make sure we have all parameters filled in --
If request(param.name) <> empty then
param.Value = request(param.name)
Else

'--- we have an empty parameter do not run report –-
blnRunReport = False
response.write "ja echt?"
End if

'--- provide the text fields for parameter input --
Response.write param.name & " <input type=text name=""" &_
param.name & """ value=""" & request(param.name) & """>" & "<BR>"
Next
Else
Response.write "No Parameters Found for this Query:" & qry.Name &
"<BR>"
End if

qry.Execute

'--- export the report to the selected format --
MyDoCmd.OutputTo 3, strReportName, "Rich Text Format (*.rtf)",
PATH & "\www\reports\report.rtf"
'--- Close the Query --
qry.Close

'--- close the report --
MyDoCmd.Close 3, strReportName, 2 '2=saveno 3=Report

'--- clean up objects used --

It goes wrong at the qry.Execute
I know that you can't execute a select query, and need a recordset for
that.
I just want to get rid of the popup dialogs for filling in the
parameters.

Any ideas?
Jul 22 '05 #1
1 2926
You can run into lots of problems opening instances of Access directly from
asp pages.
While it might work, if you ever get any kind of concurrency on your web
site your server
could be in trouble from the instances of Access opening and closing.

We have been selling a solution to run Access reports over the web for a few
years now you can download
our eval and try it out at:

RPT Software
http://www.rptsoftware.com

Most people develop web sites to produce reports in PDF format, with Excel
being second favorite choice
and RTF probably third.

HTH,
Mark Andrews

PS: For more details just send me an email to the support email at RPT
Software.

"Joris Kempen" <jo**********@groupsupport.com> wrote in message
news:ac**************************@posting.google.c om...
Hi people,

I know that the question has come around sometimes:
How to open an Access Report using ASP and export it to for example
RTF.

I'm trying to implement the first method of David Cline:

http://www.15seconds.com/issue/981216.htm

The first section describes how it should be done, and it sounds good
to me.

Way of working:

1. open Access object
2. open the needed database
3. open the report fromthe database
4. open the query that belongs to the report
5. fill the parameters from the query from a HTML form, if the params
are not filled, display the HTML form
6. execute the query with params, so the report gives the correct data
7. export the report to RTF format

every step works in this process, except step 6. Dave Cline's example
states a:
qry.execute

then I get an:
Error Type:
DAO.QueryDef (0x800A0BF9)
Cannot execute a select query.

This is quite logical, because the query is a select query.

If I leave out step 6, I get dialog popupboxes where I need to fill in
the parameters for the query, and I don't want that.

Anyone have an idea what I should change?
(I know this isn't the most nicest solution for the server, but it's
only for inhouse use)

some code snippets:

strReportName = "frmPOST_DATUM"
blnRunReport = True

'--- create an instance of Access --
set mobjAccess = createobject("access.application.11")
mobjAccess.OpenCurrentDatabase
"C:\Inetpub\wwwroot\kempen\database\post.mdb"
mobjAccess.Visible = False

'--- the DoCmd object is the easiest way to open a report --
Set MyDoCmd = mobjAccess.DoCmd
MyDoCmd.OpenReport strReportName, 1 '1=design, 0=normal, 2=preview

'--- create a reference to the now open report --
Set rpt = mobjAccess.Reports(0)

'--- Open the Query the report is based upon -
Set qry = mobjAccess.CurrentDb.QueryDefs("qryPOST_REPORT_DAT UM")

'--- loop through the queries parameters --
If qry.Parameters.Count > 0 then
Response.write "<form action=""report.asp"" method=""post"">"

For Each param In qry.Parameters

'--- to print the report make sure we have all parameters filled in --
If request(param.name) <> empty then
param.Value = request(param.name)
Else

'--- we have an empty parameter do not run report --
blnRunReport = False
response.write "ja echt?"
End if

'--- provide the text fields for parameter input --
Response.write param.name & " <input type=text name=""" &_
param.name & """ value=""" & request(param.name) & """>" & "<BR>"
Next
Else
Response.write "No Parameters Found for this Query:" & qry.Name &
"<BR>"
End if

qry.Execute

'--- export the report to the selected format --
MyDoCmd.OutputTo 3, strReportName, "Rich Text Format (*.rtf)",
PATH & "\www\reports\report.rtf"
'--- Close the Query --
qry.Close

'--- close the report --
MyDoCmd.Close 3, strReportName, 2 '2=saveno 3=Report

'--- clean up objects used --

It goes wrong at the qry.Execute
I know that you can't execute a select query, and need a recordset for
that.
I just want to get rid of the popup dialogs for filling in the
parameters.

Any ideas?

Jul 22 '05 #2

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

Similar topics

7
by: Teri Welch | last post by:
Hello, We maintain a VB6 front-end application using an Access 2000 database. All code and forms are in VB6. The program also uses several queries/reports defined in Access. For corporate...
3
by: Gheaci Maschl | last post by:
Hi all! I would like to have your opinion about my problem and my proposal how to solve it: Ingredients: - BTriev database - Crystal Reports - maybe MS Access - Liinos6 (small ERP software)
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
16
by: cyranoVR | last post by:
This is the approach I used to automate printing of Microsoft Access reports to PDF format i.e. unattended and without annoying "Save As..." dialogs, and - more importantly - without having to use...
6
by: Bob Alston | last post by:
I am looking for Access reporting add-in that would be easy to use by end users. My key focus is on selection criteria. I am very happy with the Access report writer capabilities. As far as...
13
by: salad | last post by:
Hi Guys: I was stuck. I needed to send a report to a file. My beautiful report(s) in Access were going to require loss of formatting with RTFs, a PITA in WordMailMerge, sending it as a text...
3
by: Parasyke | last post by:
I see a lot of jobs advertized for people knowing Crystal Reports. I tried to use this platform 6 years ago and found it awkward and difficult. I find Access, using ODBC, to grab data and build...
16
by: JoeW | last post by:
I'm utilizing a database that I created within MS Access within a program I've created in VB.NET. I am using the VB front end to navigate the information, but want to be able to print a report,...
0
by: Mark Gold | last post by:
Hi! We have a VB application using Crystal Reports 6 that has worked successfully on hundreds of systems for over 10 years. Now, on one network, the application and access database does not close....
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
muto222
php
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.