Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

ActiveX MapPointControl: How to find county from City, State

This is a discussion on ActiveX MapPointControl: How to find county from City, State within the MapPoint Desktop Discussion forums, part of the Map Forums category; I'm using the MapPoint control in an Access application. I would like to write a program to get the county ...

  1. #1
    UncleJaz is offline Junior Member White Belt
    Join Date
    Aug 2005
    Posts
    8

    ActiveX MapPointControl: How to find county from City, State

    I'm using the MapPoint control in an Access application.

    I would like to write a program to get the county for each city and state in a table of store locations.

    The map I am opening with my control also has many territories defined which are composed of groupings of counties. I'm really trying to get the territory name for each city/state in my retail outlet table.

    My original approach was to derive the county that a city was in and then cross reference with my territory/county table to derive the territory, but it would be more direct just to derive the territory based on the city/state of a location.

    Has anyone ever done this or have a suggestion?

    Thanks in advance

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    You an make a Location object based on the coordiantes.
    A Location object has a StreetAddress property. This has a City and Country property that you can use from VBA.

  3. #3
    UncleJaz is offline Junior Member White Belt
    Join Date
    Aug 2005
    Posts
    8

    I'm looking for the county a city is in...

    Thanks Wilfred, your reply about the location object having a streetaddress was helpful as I scrape my knuckles trying to learn this stuff. However, I'm looking for the County instead of countRy.

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

  5. #5
    UncleJaz is offline Junior Member White Belt
    Join Date
    Aug 2005
    Posts
    8

    County definition

    Counties are subdivisions of most states (US). All states have subdivisions but in a few they are called something else.

    Mappoint considers all state subdivisions in US as counties (geoShowDataByRegion2). In Europe there are also counties and/or provinces.

    My territories are defined by groups of counties and that's why I'm tyring to find the county that a given city is located in.

  6. #6
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    Thanks for explaining, we have provinces here so I understeand now. Nice word county But I dont know sorry. I hope someone else drops in here with some advice.

  7. #7
    UncleJaz is offline Junior Member White Belt
    Join Date
    Aug 2005
    Posts
    8

    I found a way to do this...

    I found a way to find the county for a given city and state. I just wanted to follow up with this thread.

    If anyone wants to know how I got it done, email me.

  8. #8
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

  9. #9
    UncleJaz is offline Junior Member White Belt
    Join Date
    Aug 2005
    Posts
    8

    Finding county for given city/state

    Here's the approach I used to find the county of a city in pseudocode:

    Sub Procedure GetCountyForCity(<strCity>, <strState>) as String
    1. Get map object (active map)...objMap
    2. Declare and set a location object:
    >objLoc = objMap.FindResults(<strCity> & ", " & <strState>).Item(1)
    3. Go to and select the location:
    >objLoc.GoTo
    >objLoc.Select
    4. Declare and set a Results object:
    >objRes = objMap.ObjectsFromPoint(objMap.LocationToX(objLoc) , objMap.LocationToY(objLoc))
    5. Declare a set a boolean county found flag and temp county name variable
    >bCountyFound = False
    >strCounty = ""
    6. Step through the results and find the object with type = 17 (geoShowDataByRegion2 for US counties)
    >For i = 2 To objRes.Count 'index of 1 has no type and generates error
    >>>If objRes.Item(i).Type = 17 Then
    >>>>>>strCounty = objRes.Item(i).Name 'County found!
    >>>>>>bCountyFound = True
    >>>>>>Exit for
    >>>End If
    7. Return the results
    >GetCountyForCity = strCounty
    End Sub

    In the calling procedure, you can test for "" county to see if you got one.

    Specific syntax of course dependent on the language you'll be using.
    Hope this is clear...let me know if you have questions.

  10. #10
    UncleJaz is offline Junior Member White Belt
    Join Date
    Aug 2005
    Posts
    8

    Oops!

    In the pseudocode I just posted, the bCountyFound flag is not really needed. It was left over from earlier effort and I forgot to remove it.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How do you find the territory for a given city and state
    By UncleJaz in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 04-05-2006, 11:50 AM
  2. Lat Long for County and State
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-24-2005, 07:20 PM
  3. find city name & state name on mouse move event
    By Atul22 in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 10-15-2004, 05:28 AM
  4. Validating City/State Names
    By jbendiner in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 08-06-2004, 03:33 PM
  5. How do I map county data? Do I put state and count....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 07-08-1999, 07:16 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25