Connecting Access 07 to Google Earth via KML TROUBLE!

McAccess

New member
Local time
Today, 00:51
Joined
Nov 12, 2009
Messages
3
Amateur here.
I am trying to link my Access 07 DB to my Google Earth Program via new KML file creation. In other words make a single pin on my map from apartment data (address) that I have in my database. I have successfully done the job. However the VBA portion of my process seems to break down for no apparent reason. When I open the DB and run the process it works perfectly. Try it a couple of more times without closing the DB and the VBA fails to create the file. Below is my code for the "Create KML" portion of the process.

Your help is GREATLY appreciated.

Code:
Option Compare Database
Public Function runGELinkSub()
'Vinces GEarth Link Suckas
DoCmd.OpenTable "GELinkTempTable"
'Export data to text file
 
Dim MyDB As Database
Dim MyRS As Recordset
Dim fld As Field
Dim strText As String
Dim MyTableName As String
Dim QryOrTblDef As String
QryOrTblDef = "GELinkTempTable"
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset(QryOrTblDef)
 
Open "AccessEarthLink.KML" For Output Shared As #1
 
Print #1, "<?xml version=""1.0"" encoding=""UTF-8""?>"
Print #1, "<kml xmlns=""[URL]http://earth.google.com/kml/2.1[/URL]"">"
Print #1, "<Document>"
Print #1, "  <name>Access Import</name>"
Print #1, "        <open>1</open>"
With MyRS
    Print #1, "            <Placemark>"
    'Print #1, "                <Point>"
    strText = "                 <address> " & MyRS.Fields(0) & "</address>"
    Print #1, strText
    strText = "                 <description><![CDATA[" & MyRS.Fields(2) & "]]></description>"
    Print #1, strText
    strText = "                 <name>" & MyRS.Fields(1) & "</name>"
    Print #1, strText
    'Print #1, "                    <Snippet maxLines="; 2; "></Snippet>"
    'Print #1, "                    <address><![CDATA[]]></address>"
    'Print #1, "                    <LookAt>"
    'Print #1, "                    </LookAt>"
    'Print #1, "                </Point>"
    Print #1, "            </Placemark>"
End With
Print #1, "   </Document>"
Print #1, "</kml>"
Close #1
MyRS.Close
Set MyRS = Nothing
Set MyDB = Nothing
Set fld = Nothing
'You Gotta Love the Hyperlink
GoHyperlink "C:\Users\Vince\Documents\AccessEarthLink.kml"
'Shell "AccessEarthLink"
End Function
 

Users who are viewing this thread

Back
Top Bottom