Crear KML desde Access con VBA
Hace algunos ayeres publiqué una pregunta acerca de como crear un archivo KML a partir de una base de datos en Access.
Hasta el día de hoy lo he logrado, con mucho trabajo pero funciona, el detalle es el siguiente y espero alguien me pueda apoyar:
Mi código es el siguiente:
Private Sub cmdAllSpottersPlot_Click() 'Written by Rex Morgan with help from Access World Forums 'this version as of 8-21-2010 'Declaring the variables Dim db As DAO.Database Dim QD As DAO.QueryDef Dim where As Variant Dim kmlAnswer As String 'assigning value to db Set db = CurrentDb 'Delete existing dynamic query, trap error if it does not exist. On Error Resume Next 'deleting the last version of "MyQuery" db.QueryDefs.Delete ("Qrykmlsitios") On Error GoTo 0 'assigning value to QD Set QD = db.CreateQueryDef("Qrykmlsitios", "SELECT tblDirecciones.IdSitio, tblDirecciones.NombreSitio, tblDirecciones.LatiDecimal, tblDirecciones.LongDecimal, tabSitios.StatusGral FROM tabSitios INNER JOIN tblDirecciones ON tabSitios.IdSitio = tblDirecciones.IdSitio;") 'executing the command to Open a Query titled "MyQuery" 'DoCmd.OpenQuery "Qrykmlsitios" ' DoCmd.OpenReport "MyQuery", acViewPreview 'setting up the message box asking whether or not you want to map the results kmlAnswer = MsgBox("Would you like to map this query in Google Earth?", vbApplicationModal + vbYesNo + vbDefaultButton2, "Map in Google Earth") If kmlAnswer = vbYes Then Coomand91_Click End If 'executing the command to Close the form DoCmd.Close acQuery, Me.Name End Sub
Enfoco mi pregunta a la parte en donde se asignan los valores a la variable QD, como pueden ver es una consulta:
Tengo mas de 2mil registros en la tabla "tblDirecciones", por lo que no deseo que se muestren todos sino que me gustaría poder aplicar un filtro antes de crear el .KML, por ej. Los sitios que tengan el statusgeneral en 'OPERANDO', y asi reduzca los sitios a mostrar en el kml. No sé de que manera hacer eso.
1 respuesta
Respuesta de Sveinbjorn El Rojo
2