Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access VB Code Mapping to Mappoint Incorrectly

Status
Not open for further replies.

TaylorTot

Technical User
Dec 23, 2003
96
0
0
US
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.
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!!
 
TaylorTot,
Are you passing the region as ohtercity and zip code as region?
object.FindAddressResults([Street], [City], [red][OtherCity][/red], [Region], [PostalCode], [Country])
Code:
...
Set objLoc = objMap.FindAddressResults(rstProps!Address1, rstProps!City,[b][red] ,[/red][/b] rstProps!StateCode, rstProps!Zip)
...

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Yes, that's exactly what I was doing, thank you so much for your help :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top