View Single Post
  #8  
Old May 11th, 2007, 11:39 AM posted to microsoft.public.access.externaldata,microsoft.public.access.reports,microsoft.public.access
efandango
external usenet poster
 
Posts: 489
Default Creating a custom text export file (inc. header & footer) from

John,

I now get this error in the line: Close rsR:
(highlighting the word 'Close')

Compile error:
Type mismatch:



"John Nurick" wrote:

My fault - though I warned you it was air code. Should be
CurrentDB.OpenRecordset("Generate_KML", dbOpenSnapshot)
not
CurrentDB.Open("Generate_KML")




On Thu, 10 May 2007 16:41:00 -0700, efandango
wrote:

John,

Just ignore the previous two posts from me.

This is how far i have got in adapting your code

Private Sub Test_Click()
Dim rsR As DAO.Recordset
Dim strLine As String
Dim lngFN As Long

'Create empty text file
lngFN = FreeFile()
Open "W:\Folder\Addresses.kml" For Output As #lngFN

'Output header
'NB: need to double quotes in literal strings
Print #lngFN, "?xml version="; 1#; " encoding=""UTF-8""?"
Print #lngFN, "kml xmlns=""http://earth.google.com/kml/2.0"""
Print #lngFN, "Document"
Print #lngFN, "nameAddress List/name"
Print #lngFN, "Folder"
Print #lngFN, "nameLocations/name"
Print #lngFN, "open1/open"
'...

'Output address
Set rsR = CurrentDb.Open("Generate_KML")
Print #lngFN, rsR.Fields("KML_Address")
Close rsR

'Output footer
Print #lngFN, "/Folder"
Print #lngFN, "/Document"
Print #lngFN, "/kml"
'...

Close #lngFN

End Sub


But i get an error message: 'Method or Data Member not found' on the word
'Open' in the following line:

Set rsR = CurrentDb.Open("Generate_KML")

It suggests that something is mispelled or wrong reference, so I was worried
that the query it was calling was two seperate words, so I changed it to one
whole_word. But it still reports the same error message.

Can you help me with this?

"John Nurick" wrote:

There are many ways of skinning this cat. I'd probably do something like
this (air code):

Dim rsR As DAO.Recordset
Dim strLine As String
Dim lngFN As Long

'Create empty text file
lngFN = FreeFile()
Open "D:\Folder\Addresses.kml" For Output As #lngFN

'Output header
'NB: need to double quotes in literal strings
Print #lngFN, "?xml version="1.0" encoding=""UTF-8""?"
Print #lngFN, "kml xmlns=""http://earth.google.com/kml/2.0"""
'...

'Output address
Set rsR = CurrentDB.Open("My Query")
Print #lngFN, rsR.Fields("kml Address")
Close rsR

'Output footer
Print #lngFN blah blah

Close #lngFN

On Thu, 10 May 2007 10:35:01 -0700, efandango
wrote:

I have an address query which ouputs a single field to text strings for
Google Earth .kml file format parameters.

The problem is that the .kml file requires a header and footer text to be
inserted. Does anyone know how I can pre-insert the Header and Footer into a
standard text file, and then save it with a ‘.kml’ extension, for example
‘Addresses.kml’

This is the Header:

?xml version="1.0" encoding="UTF-8"?
kml xmlns="http://earth.google.com/kml/2.0"
Document
nameAddress List/name
Folder
nameLocations/name
open1/open

Output Field: [kml Address]

This is the Footer:

/Folder
/Document
/kml


--
John Nurick [Microsoft Access MVP]

Please respond in the newsgroup and not by email.