Hello,
I have an access form that is mapping addresses from a query into Mappoint. Unfortunately, a few of the addresses are mapping incorrectly. Below is my code and an example of what is mapping wrong.
the address: 7125 W. Jefferson Ave. Suite 100, Lakewood, CO 80235 is mapping to Jefferson Ct., Lakewood NJ
Any help would be greatly appreciated!!
I have an access form that is mapping addresses from a query into Mappoint. Unfortunately, a few of the addresses are mapping incorrectly. Below is my code and an example of what is mapping wrong.
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:
MsgBox Err.Number & " - " & Err.Description
Resume MapSelectedProperties_Err_Exit
End Sub
the address: 7125 W. Jefferson Ave. Suite 100, Lakewood, CO 80235 is mapping to Jefferson Ct., Lakewood NJ
Any help would be greatly appreciated!!