Generate report manually

  • Thread starter Thread starter HDI
  • Start date Start date
H

HDI

Hi,

Is it possible in access 2003 to generate a report based on a
recordset or loop through the recordset by myself.

I know it is possible to put my values in a temporary table and link
those to the report but if above is possible it should be easier.

Thx
 
Yes, in Access 2003, the Report object has a Recordset property that you can
set to either an ADO or DAO recordset. Assuming you've got a recordset named
MyRecordset, you can use it on a report named MyReport like:

Set Reports("MyReport").Recordset = MyRecordset

(note that the report must be open before you can do this)
 
Yes, in Access 2003, the Report object has a Recordset property that you can
set to either an ADO or DAO recordset. Assuming you've got a recordset named
MyRecordset, you can use it on a report named MyReport like:

Set Reports("MyReport").Recordset = MyRecordset

(note that the report must be open before you can do this)

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no private e-mails, please)









- Tekst uit oorspronkelijk bericht weergeven -

Tried it but i receive error 2593, the function is not available in
MDB.
 
In what event did you try to run it? What's the actual code you're running.

And I don't know whether or not it matters, but is your application in
Access 2000 format, or Access 2002/2003 format?

(Sorry, I don't have Access 2003 installed on this machine, so I can't test)
 
In what event did you try to run it? What's the actual code you're running.

And I don't know whether or not it matters, but is your application in
Access 2000 format, or Access 2002/2003 format?

(Sorry, I don't have Access 2003 installed on this machine, so I can't test)

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)








- Tekst uit oorspronkelijk bericht weergeven -

Tried it:
- in 2000 format and 2002/2003 format.
- event report_open and in a button onclick event where I first
opened the report.

Code:

Dim cn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim ssql As String

Set cn = CurrentProject.Connection
strsql = "SELECT ....."
rst.Open ssql, cn, , , adCmdText
Set Reports("rptTest").Recordset = rst --> error 2593, the function is
not available in MDB.
 
HDI said:
Tried it:
- in 2000 format and 2002/2003 format.
- event report_open and in a button onclick event where I first
opened the report.

Code:

Dim cn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim ssql As String

Set cn = CurrentProject.Connection
strsql = "SELECT ....."
rst.Open ssql, cn, , , adCmdText
Set Reports("rptTest").Recordset = rst --> error 2593, the function is
not available in MDB.

You've declared the variable as ssql, and that's what you're using when you
open the recordset, but you're assigning the SQL string to a variable named
strsql. Is that just a typo? (it's far better to use copy-and-paste when
showing code in posts!)

Where are you declaring rst? I don't normally use this approach, so I can't
remember, but it may very well be a case that you need that to be declared
as a global object.

As well, see whether

Set Me.Recordset = rst

(in the report's Open event) works any better.
 
You've declared the variable as ssql, and that's what you're using when you
open the recordset, but you're assigning the SQL string to a variable named
strsql. Is that just a typo? (it's far better to use copy-and-paste when
showing code in posts!)

Where are you declaring rst? I don't normally use this approach, so I can't
remember, but it may very well be a case that you need that to be declared
as a global object.

As well, see whether

Set Me.Recordset = rst

(in the report's Open event) works any better.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -

Same thing.

I read that this is only possible in Access 2003 when you use ADP.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top