Hi, I am trying to create a kml file after an Access query/table that contains one or more geographic points. The associated data is listed in the subsequent columns/fields although they do not always contain values and can be more than 150. I would like the resulting kml file to produce a box with a table or list that is populated only with those fields that actually have a value and that shows when one clicks the corresponding icon in GoogleEarth as it is doing now, except that my example only has two fields that I typed myself. Is this possible? What I am trying to avoid is the typing of each and every field in the description part. Thanks for your help and suggestions.
The code I have so far is as follows:
The code I have so far is as follows:
Code:
Option Compare Database
Private Sub Command33_Click()
DoCmd.OpenQuery "qryCoords_Values"
Dim MyDB As Database
Dim MyRS As Recordset
Dim fld As Field
Dim strText As String
Dim QryDef As String
QryDef = "qryCoords_Values"
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset(QryDef)
Open "K:\Map.kml" For Output Shared As #1
Print #1, "<?xml version=""1.0"" encoding= ""UTF-8""?>"
Print #1, "<kml xmlns="" .... earth.google.com/kml/2.1"">"
Print #1, "<Document>"
Print #1, " <name>Map.kml</name>"
With MyRS
Do Until .EOF
Print #1, " <Placemark>"
Print #1, strText
Print #1, " <name>" & MyRS.Fields(0) & MyRS.Fields(1) & "</name>"
Print #1, strText
Print #1, " <visibility>1</visibility>"
Print #1, strText
Print #1, " <description><![CDATA[Value1 = " & MyRS.Fields(7) & "<br>" & "Value2 = " & MyRS.Fields(8) & "]]></description> " 'This is where I need to include all the data fields.
Print #1, strText
Print #1, " <Point>"
Print #1, strText
Print #1, " <coordinates>" & MyRS.Fields(2) & "," & MyRS.Fields(3) & ", 0</coordinates>"
Print #1, " </Point>"
Print #1, " </Placemark>"
.MoveNext
Loop
End With
Print #1, "</Document>"
Print #1, "</kml>"
Close #1
MyRS.Close
Set MyRS = Nothing
Set MyDB = Nothing
Dim retval
retval = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler " & "K:\Map.kml", vbNormalFocus)
End Sub