Results 1 to 6 of 6
  1. #1
    graviz is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Sep 2009
    Posts
    48

    Please Help - VBA Access & MapPoint

    I'm trying to figure out how to take a table in access an map it as a territory in access. I've done some searching and and found some articles on MapPoint Articles - MP2K Magazine and in these forums but have had no luck with what I'm trying to do. Here's what I have:



    -A table called Office_Zips (two fields, Office Name, and Zip Code)

    This is my code so far:

    Public Function test_map()
    Dim oApp As MapPoint.Application
    Set oApp = CreateObject("mappoint.application.na.16")
    oApp.Visible = True

    End Function

    All I would like to do is have a new territory map created using the information in the table as the source.

    Thanks!

  2. #2
    c_smithwick is offline Underpaid Programmer
    Windows 7 Access 2003
    Join Date
    Jan 2010
    Location
    Lakeside, CA
    Posts
    49
    Try a variant of the following:

    Code:
    Sub mapData()
        Dim objApp As New MapPoint.Application
        Dim objDataSets As MapPoint.DataSets
        Dim objDataSet1 As MapPoint.DataSet
        Dim objDataMap1 As MapPoint.DataMap
        Dim strDataSource As String
        Dim lColorRange As Long
        objApp.Visible = True
        objApp.UserControl = True
        
        lColorRange = 15 'full spectrum
        strDataSource = "" 'String containing Path to Access Database and Table - 'C:\Data\Test.mdb!tblZips'
        Set objDataSets = objApp.ActiveMap.DataSets
        
        Set objDataSet1 = objDataSets.ImportData(zDataSoure, , geoCountryDefault, , geoImportFirstRowIsHeadings)
        Set objDataMap1 = objDataSet1.DisplayDataMap(geoDataMapTypeShadedArea, , , , , , lColorRange)
        
        objApp.ActiveMap.MapStyle = geoMapStyleData
        
        objDataSet1.ZoomTo
        
    End Sub
    Here's a helpful link:

    http://msdn.microsoft.com/en-us/library/aa562381.aspx

  3. #3
    graviz is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Sep 2009
    Posts
    48
    Quote Originally Posted by c_smithwick View Post
    Try a variant of the following:

    Code:
    Sub mapData()
        Dim objApp As New MapPoint.Application
        Dim objDataSets As MapPoint.DataSets
        Dim objDataSet1 As MapPoint.DataSet
        Dim objDataMap1 As MapPoint.DataMap
        Dim strDataSource As String
        Dim lColorRange As Long
        objApp.Visible = True
        objApp.UserControl = True
     
        lColorRange = 15 'full spectrum
        strDataSource = "" 'String containing Path to Access Database and Table - 'C:\Data\Test.mdb!tblZips'
        Set objDataSets = objApp.ActiveMap.DataSets
     
        Set objDataSet1 = objDataSets.ImportData(zDataSoure, , geoCountryDefault, , geoImportFirstRowIsHeadings)
        Set objDataMap1 = objDataSet1.DisplayDataMap(geoDataMapTypeShadedArea, , , , , , lColorRange)
     
        objApp.ActiveMap.MapStyle = geoMapStyleData
     
        objDataSet1.ZoomTo
     
    End Sub
    Here's a helpful link:

    http://msdn.microsoft.com/en-us/library/aa562381.aspx
    I tired the code and map point opens but then I recieve an error "The parameter is incorrect" and highlights "Set objDataSet1 = objDataSets.ImportData(zDataSoure, , geoCountryDefault, , geoImportFirstRowIsHeadings)"

    Any ideas?

  4. #4
    c_smithwick is offline Underpaid Programmer
    Windows 7 Access 2003
    Join Date
    Jan 2010
    Location
    Lakeside, CA
    Posts
    49
    Found a typo. Change:

    Code:
    Set objDataSet1 = objDataSets.ImportData(zDataSoure, , geoCountryDefault, , geoImportFirstRowIsHeadings)
    To

    Code:
    Set objDataSet1 = objDataSets.ImportData(strDataSource, , geoCountryDefault, , geoImportFirstRowIsHeadings)"

  5. #5
    graviz is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Sep 2009
    Posts
    48
    Quote Originally Posted by c_smithwick View Post
    Found a typo. Change:

    Code:
    Set objDataSet1 = objDataSets.ImportData(zDataSoure, , geoCountryDefault, , geoImportFirstRowIsHeadings)
    To

    Code:
    Set objDataSet1 = objDataSets.ImportData(strDataSource, , geoCountryDefault, , geoImportFirstRowIsHeadings)"
    So now I'm recieving the error "Cannot import data because a connection to the database could not be established" and highlights the same section of code.

    Sub mapData()
    Dim objApp As New MapPoint.Application
    Dim objDataSets As MapPoint.DataSets
    Dim objDataSet1 As MapPoint.DataSet
    Dim objDataMap1 As MapPoint.DataMap
    Dim strDataSource As String
    Dim lColorRange As Long
    objApp.Visible = True
    objApp.UserControl = True

    lColorRange = 15 'full spectrum
    strDataSource = "\\Mer2-corpfs1\dnsc\Resource Management\Map.mdb!Raw" 'String containing Path to Access Database and Table - 'C:\Data\Test.mdb!tblZips'
    Set objDataSets = objApp.ActiveMap.DataSets

    Set objDataSet1 = objDataSets.ImportData(strDataSource, , geoCountryDefault, , geoImportFirstRowIsHeadings)
    Set objDataMap1 = objDataSet1.DisplayDataMap(geoDataMapTypeShadedAre a, , , , , , lColorRange)

    objApp.ActiveMap.MapStyle = geoMapStyleData

    objDataSet1.ZoomTo

    End Sub

  6. #6
    c_smithwick is offline Underpaid Programmer
    Windows 7 Access 2003
    Join Date
    Jan 2010
    Location
    Lakeside, CA
    Posts
    49
    Make sure your network path is correct and is your table really just named "Raw"? If so, then I'm stumped too. This was posted as just untested "air code" but it sounds as if you are on the right track. If you are running this from within the actual database itself try the following substitution

    Code:
    strDataSource = CurrentDb.Name & "!Raw"

Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums