I have read through this topic and applied what I learned. Here is my code:
Private Sub Command33_Click()
DoCmd.OpenQuery "qryCreateKML"
'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 = "qryCreatKML"
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset(QryOrTblDef)
Open "D:\KMLTest.kml" For Output Shared As #1
Print #1, "<?xml version=""1.0"" encoding=""UTF-8""?>"
Print #1, "<kml xmlns=""
http://earth.google.com/kml/2.1"">"
Print #1, "<Document>"
Print #1, " <name>KMLTest.kml</name>"
Print #1, " <Folder>"
Print #1, " <name>Test</name>"
Print #1, " <open>1</open>"
Print #1, " <Folder>"
Print #1, " <name>KML</name>"
Print #1, " <open>1</open>"
Print #1, " <Snippet maxLines=""2"">Whatever</Snippet>"
Print #1, " <description><![CDATA[]]></description>"
With MyRS
Do Until .EOF
Print #1, " <Placemark>"
'Print #1, " <Point>"
strText = " <description><![CDATA[FIELDNAME0:" & MyRS.Fields(0) & "<br>FIELDNAME1:" & MyRS.Fields(1) &
"]]></description>"
Print #1, strText
strText = " <address> " & MyRS.Fields(0) & "</address>"
Print #1, strText
strText = " <name>" & MyRS.Fields(1) & "</name>"
Print #1, strText
'Print #1, " <Snippet maxLines="; 2; "></Snippet>"
'Print #1, " <description><![CDATA[]]></description>"
'Print #1, " <LookAt>"
'Print #1, " </LookAt>"
'Print #1, " </Point>"
Print #1, " </Placemark>"
.MoveNext
Loop
End With
Print #1, " </Folder>"
Print #1, " </Folder>"
Print #1, " </Document>"
Print #1, "</kml>"
Close #1
MyRS.Close
Set MyRS = Nothing
Set MyDB = Nothing
'Shell "ENTERKMLFILENAMEHERE"
End Sub
I get an error that says "Too few parameters. Expected 1."
Addition info:
When I run the query it gives me a table as follows
GeoLat | GeoLong | EventID |
----------------------------------
12 | 123 | Name |
I also have a query that returns
UpperLeft | EventID |
----------------------------------
12 N , 110 E| Name |
Can anyone please help me format this code to work with my query?
Thanks!