Please Help - VBA Access & MapPoint

graviz

Registered User.
Local time
Yesterday, 23:59
Joined
Aug 4, 2009
Messages
167
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!
 
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
 
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?
 
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(geoDataMapTypeShadedArea, , , , , , lColorRange)

objApp.ActiveMap.MapStyle = geoMapStyleData

objDataSet1.ZoomTo

End Sub
 

Users who are viewing this thread

Back
Top Bottom