Hello,
I have an access form that runs a query based on an address entered by
the end user. The query returns all vendors within 15 miles. I have
been successful in mapping the results of the query, but I would also
like to map the address that is entered in the form. . . this is where
I'm having trouble. Below is the code I am using to map the query
results. Can someone tell me how I can get the address entered to map
also (with different symbol).
Thanks for your help in advance
I have an access form that runs a query based on an address entered by
the end user. The query returns all vendors within 15 miles. I have
been successful in mapping the results of the query, but I would also
like to map the address that is entered in the form. . . this is where
I'm having trouble. Below is the code I am using to map the query
results. Can someone tell me how I can get the address entered to map
also (with different symbol).
Code:
Sub MapSelectedProperties()
'Map the selected properties
On Error GoTo MapSelectedProperties_Err_Exit
Dim db As Database
Dim rstProps As DAO.Recordset
Dim qdf As QueryDef
Dim objLoc As MapPoint.Location
Dim objMap As MapPoint.map
Dim objPushPin As MapPoint.Pushpin
Dim strMsg As String
Dim i As Integer
i = 0
Set db = CurrentDb()
'Load the selected properties into a recordset
Set qdf = CurrentDb.QueryDefs("Get20Mile_SelQry")
qdf.Parameters(0) = Forms![frmMain]![txtZipCode]
Set rstProps = qdf.OpenRecordset(dbOpenDynaset)
Set Recordset = rstProps
'Make sure at least one property was selected
If rstProps.RecordCount > 0 Then
'Load Map
If LoadMap() Then
'Open the form containing the map
FormOpen "frmMap"
Set objMap = gappMP.ActiveMap
'Place a pushpin on the map for each selected property
While Not rstProps.EOF
i = i + 1
Set objLoc = objMap.FindAddressResults(rstProps!Address1,
rstProps!City, , rstProps!StateCode, rstProps!Zip)(1)
Set objPushPin = objMap.AddPushpin(objLoc, rstProps!Address1)
objPushPin.Name = CStr(i)
objPushPin.Note = rstProps!CompanyName
objPushPin.BalloonState = geoDisplayBalloon
objPushPin.Symbol = 77
objPushPin.Highlight = True
rstProps.MoveNext
Wend
'Show all pushpins on the map display
objMap.DataSets.ZoomTo
Else
strMsg = "Unable to load map."
MsgBox strMsg, vbOKOnly + vbExclamation, APP_NAME
End If
Else
strMsg = "No properties selected."
MsgBox strMsg, vbOKOnly + vbExclamation, APP_NAME
End If
MapSelectedProperties_Err_Exit:
On Error Resume Next
Set objPushPin = Nothing
Set objLoc = Nothing
Set objMap = Nothing
If Not (rstProps Is Nothing) Then rstProps.Close
db.Close
Exit Sub
MapSelectedProperties_Err:
Resume MapSelectedProperties_Err_Exit
End Sub
Thanks for your help in advance