do loop with outputto rtf (1 Viewer)

ddmcn

Registered User.
Local time
Today, 01:17
Joined
Sep 12, 2002
Messages
73
Hi, all...here's the deal. I have a report that I can run that creates a very long report organized by country names. What I would like to do is write a script that will export the report into rtf files by country. In other words I would like a module that would write a separate rtf file for each country giving it a name of [countryname].rtf.

I understand the syntax on the OUTPUTTO but I'm not sure how to write the module to create separate reports for each country. I presume I would have to use FOR EACH in my DO LOOP.

Any suggestions?

TIA
 

dan-cat

Registered User.
Local time
Today, 06:17
Joined
Jun 2, 2002
Messages
3,433
I'm bored today so I had a crack at it for you.

Would appreciate any opinions on how I've approached this :)
 

Attachments

  • country.zip
    23.9 KB · Views: 136

ddmcn

Registered User.
Local time
Today, 01:17
Joined
Sep 12, 2002
Messages
73
Query vs Table

dan_kat, another question. Your event procedure showed the following declarations:

Dim db As Database
Dim rec As Recordset
Dim qdf As QueryDef
Dim strSQL As String
Dim intId As Integer
dim strPathCountry As String

Set db = CurrentDb()
Set rec = db.OpenRecordset ("tblCountry")
Set qdf = db.QueryDefs ("qryCountry")


My questions are:

If my recordset is a query (because the contents of my report need to come from differnt tables) and
the recordset does not exist until the query is opened, does the OpenRecordset element of the above code accomplish that?

If my recordset is a query, do I need to declare a QueryDef?

I'm sure I'll have others as I try to get this working. Thanks in advance for your help on this.
 

Mile-O

Back once again...
Local time
Today, 06:17
Joined
Dec 10, 2002
Messages
11,316
Re: Query vs Table

ddmcn said:
Code:
Dim db As Database
Dim rec As Recordset
Dim qdf As QueryDef
Dim strSQL As String
Dim intId As Integer
dim strPathCountry As String

Set db = CurrentDb()
Set rec = db.OpenRecordset ("tblCountry")
Set qdf = db.QueryDefs ("qryCountry")

The code could do with diambiguation.

Code:
Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim qdf As DAO.QueryDef

From that it also looks like the same thing. What's the difference between tblCountry and qryCountry apart from the obvious "one's a table and one's a query" difference? Is the query sorted? Why is the table needed then?

If my recordset is a query (because the contents of my report need to come from differnt tables) and the recordset does not exist until the query is opened, does the OpenRecordset element of the above code accomplish that?

It opens a data access method to the query.

If my recordset is a query, do I need to declare a QueryDef?

No. A query is a recordset. You are more likely to use a QueryDef for creating a new query or treating it as an action query (update, delete, etc.)
 

dan-cat

Registered User.
Local time
Today, 06:17
Joined
Jun 2, 2002
Messages
3,433
Re: Re: Query vs Table

Mile-O-Phile said:


The code could do with diambiguation.

Code:
Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim qdf As DAO.QueryDef

From that it also looks like the same thing. What's the difference between tblCountry and qryCountry apart from the obvious "one's a table and one's a query" difference? Is the query sorted? Why is the table needed then?



It opens a data access method to the query.



No. A query is a recordset. You are more likely to use a QueryDef for creating a new query or treating it as an action query (update, delete, etc.)

When I asked for opinions I didn't mean cut me to ribbons :D
 

Mile-O

Back once again...
Local time
Today, 06:17
Joined
Dec 10, 2002
Messages
11,316
Re: Re: Re: Query vs Table

dan-cat said:
When I asked for opinions I didn't mean cut me to ribbons :D

I might open the attachment, look at the rest of the code, and give it the Triads' "Death by a Thousand Swords" :cool: :p
 

dan-cat

Registered User.
Local time
Today, 06:17
Joined
Jun 2, 2002
Messages
3,433
Would prefer a 'death by a thousand French actresses'. What a way to go :)
 

Mile-O

Back once again...
Local time
Today, 06:17
Joined
Dec 10, 2002
Messages
11,316
dan-cat said:
Would prefer a 'death by a thousand French actresses'. What a way to go :)

Is Brigitte Bardot still acting? I know Catherine Deneuve is. I wouldn't like that in this day and age. :cool:
 

dan-cat

Registered User.
Local time
Today, 06:17
Joined
Jun 2, 2002
Messages
3,433
ddmcn said:
Hi, all...here's the deal.

Anyway now that we've completed our part of the deal what do we get in return?

I would like a years supply of sausages wrappen in bacon.

Mile whats your poison? :p
 

Mile-O

Back once again...
Local time
Today, 06:17
Joined
Dec 10, 2002
Messages
11,316
Re: Re: do loop with outputto rtf

dan-cat said:
Mile whats your poison? :p

An ampoule of hemlock.
 

dan-cat

Registered User.
Local time
Today, 06:17
Joined
Jun 2, 2002
Messages
3,433
Fancy yourself as a bit of a socrates aye?
 

Mile-O

Back once again...
Local time
Today, 06:17
Joined
Dec 10, 2002
Messages
11,316
dan-cat said:
Fancy yourself as a bit of a socrates aye?

If so, I'd be talking to myself via dialogue. ;)
 

ddmcn

Registered User.
Local time
Today, 01:17
Joined
Sep 12, 2002
Messages
73
Access 2000

All right...now I'm gettting an error message when I try to compile the procedure. It is on the phrase:

Dim db As Database

It says: Compile Error User-Defined type not defined

Any idea why Access 2000 will not let me use "Database"

Thx
 

ddmcn

Registered User.
Local time
Today, 01:17
Joined
Sep 12, 2002
Messages
73
Type mismatch

Hmm...now I'm getting a type mismatch error on:

Set rec = db.OpenRecordset ("QRY_COUNTRY_REPORT")

It is now recognizing the "Database" element, however...one small step for man...still smaller step for mankind.

Any help on this one?
 

Mile-O

Back once again...
Local time
Today, 06:17
Joined
Dec 10, 2002
Messages
11,316
Have you said:

Code:
Dim db As Database - bad

or

Code:
Dim db As DAO.Database - good
 

ddmcn

Registered User.
Local time
Today, 01:17
Joined
Sep 12, 2002
Messages
73
Aye, I've used both...the error message is the same.
 

Mile-O

Back once again...
Local time
Today, 06:17
Joined
Dec 10, 2002
Messages
11,316
Is that a space you have between OpenRecordset and the query's name?

Code:
Dim db As DAO.Database
Dim rec As DAO.RecordSet
Set db = CurrentDb
Set rec = db.OpenRecordset("QRY_COUNTRY_REPORT")
 

ddmcn

Registered User.
Local time
Today, 01:17
Joined
Sep 12, 2002
Messages
73
Hmm...you said "uncheck" Microsoft ActiveX Data Objects 2.x Library...that made a difference.

However, now the report seems to be in an unending loop.
 

Users who are viewing this thread

Top Bottom