MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




MapPoint Automation from an Access Form

This is a discussion on MapPoint Automation from an Access Form within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; I am new to MP2K forums. I developed an Access form which employees add their daily route. The form contains ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack (4) Thread Tools Display Modes
  4 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 09-25-2007
Junior Member
White Belt
 
Join Date: Sep 2007
Posts: 5
MapPoint Automation from an Access Form

I am new to MP2K forums.

I developed an Access form which employees add their daily route. The form contains a sub-form in data-sheet (tabular) view where users add address and other information each day. (All data is stored in a database (.mdb file) on our server.) The form also contains a calendar control where one can call up routes from previous days. The sub-form is based on a query which ties to the calendar control. I want to place a button on the form which automatically launches a separate instance of MapPoint and does the following:

1. MapPoint imports addresses from the abovementioned sub-form. I would like to use the query that the form uses but am willing to take roundabout methods like exporting the day’s addresses to a temporary file.

2. Automatically places the list of addresses in MapPoint’s route planner after searching within a prescribed territory based on Zip Codes. This is to avoid searching all of North America before mapping each waypoint. (The start and end waypoints will always be the same since that is our fleet location.)

3. Finally, MapPoint automatically optimizes the route and get directions.

While I don’t expect someone to provide the VB code for all this, I would like to know if this is possible or if I’m just wasting my time. I am somewhat versed in Access but am a novice at VB. A search of the forums has, so far, provided little help for this specific application. Can anyone steer me toward some good resources? I realize this may take some time to finally get it to work.

Thanks in advance.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 09-26-2007
Senior Member
Blue Belt
 
Join Date: Dec 2002
Posts: 248
Re: MapPoint Automation from an Access Form

Hi arcturus19,

Your idea is definately possible.

1) You'll just need to export to text and import using an instance of MapPoint
2) In order to start and end at the same point, your solution will need to
move those points in code.
3) Route.Optimize and Map.CopyDirections will work.

Mike Mattys
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 12-18-2007
Junior Member
White Belt
 
Join Date: Sep 2007
Posts: 5
Re: MapPoint Automation from an Access Form

Thanks for the advice.

I've done much work since my last post. I actually have the waypoints optimizing correctly with my base as the start and end points. I only have one problem left to tackle.

Whenever there are no records in the the form and I launch my MapPoint app, it fails to load and the debugger pops up. This likely a simple fix but I have been searching for days and have not found anything close to this problem. It will only work as long as their are some records in the query/dataset. I believe this will be is a simple IF, THEN, ELSE statement about the recordset being empty. I'm apparently not using the correct syntax.

Any ideas?

Thanks in advance,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 12-29-2007
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
Re: MapPoint Automation from an Access Form

Hi,

Probably this is an exception. I don't know the right syntax in VBA, but should be something as try except (or catch) end;
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 12-31-2007
Senior Member
Blue Belt
 
Join Date: Dec 2002
Posts: 248
Re: MapPoint Automation from an Access Form

Hi.

You are using a class named 'Form' that has events such as
OnLoad()
and
OnOpen()

You need to take advantage of this by proceeding or not
proceeding with the event dependent upon whether there
are records in the form's recordsource.

In this case, do what is neccessary for Access
in the OnLoad event and determine whether you should
create an instance of MapPoint like this:

Private Sub OnOpen()
If Me.Form.RecordsetClone.RecordCount>0 Then
'Load MapPoint and process records
End If
End Sub



Mike Mattys
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 01-08-2008
Junior Member
White Belt
 
Join Date: Sep 2007
Posts: 5
Re: MapPoint Automation from an Access Form

Hi Mike:

Thanks again. That worked beautifully. I also included some data validation teqniques in the text box so one cannot leave it blank.

Yes, I am using the OnLoad event for most of my code for the for with MapPoint control. I only have a couple of hurdles to get over and I'm done, I think.

My question now is what is the best method for finding addresses in a certain geographic area? For expediancy, the users will only be typing in addresses in the route form, without city, state and zip. (West Los Angeles is actually broken into small cities so just using Los Angeles does not work well.) Currently, I am putting a string of towns like Venice and Marina Del Rey separated by comas for the default value of the City field of my table aong with CA for the default in the State field. (These are hidden from the user.)

While this works about 90% of the time, some waypoints only come up with the street and no address, particularly in Venice, CA. I have to delete the waypoint and enter the address and city in MapPoint to locate the correct address. This is odd because the city I enter is among those included in my string of cities in the imported records. Maybe using a string of zip codes is better?

Perhaps I'll get better results if MapPoint searches within zip codes or cities using VBA code instead of putting a bunch of these in my table.

Let me know what you think is the best way to increase the accuracy of my results.

Thanks in advance,

acrturus19
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 01-14-2008
Junior Member
White Belt
 
Join Date: Sep 2007
Posts: 5
Re: MapPoint Automation from an Access Form

Anyone.....?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 01-14-2008
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,480
Blog Entries: 1
Re: MapPoint Automation from an Access Form

Does it work better if users include the City?
__________________
~ Now taking orders for MapPoint 2009 ~
~
~ Upgrade to MapForums Plus membership ~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 01-14-2008
Junior Member
White Belt
 
Join Date: Sep 2007
Posts: 5
Re: MapPoint Automation from an Access Form

Anytime I include the correct city when I enter it in the route planner, It finds it. I suppose if I one entered the city in the form, it would find it as well. The point is I don't want users to have to do this. I'm trying to have the program search among a group of cities, but I don't think the code is working. Maybe Someone can look at my code and see if I haven't done that part correctly. I likely need to add more code pertaining to record matching.

If Me.Form.RecordsetClone.RecordCount > 0 Then
'Load MapPoint and process records
Dim objApp As MapPoint.Application
Dim objMap As MapPoint.Map
Dim objRoute As MapPoint.Route
Dim objFR As MapPoint.FindResults
Set rs = Me.Recordset
Set objApp = CreateObject("mappoint.application")
Set objMap = objApp.ActiveMap
Set objRoute = objMap.ActiveRoute
Dim StartPoint As MapPoint.Waypoint
Set objMap = MPC.NewMap(geoMapNorthAmerica)
MPC.Toolbars.Item("Navigation").Visible = True
MPC.Toolbars.Item("Standard").Visible = True
MPC.PaneState = MapPoint.GeoPaneState.geoPaneRoutePlanner


'Set the route start point
Index = 1
Set oloc = objMap.ActiveRoute.Waypoints.Add(objMap.FindAddres sResults("Headquarters Address Goes Here", "Los Angeles", "CA", "90031")(1))
With objRoute.Waypoints
'Map each waypoint
Do Until rs.EOF
Index = 2
Set oLocs = objMap.ActiveRoute.Waypoints.Add(objMap.FindAddres sResults(Me.job_address, "Los Angeles, Marina Del Rey, Venice, Playa Del Rey, Santa Monica, Culver City, Pacific Palisades, Beverly Hills, West Hollywood", , "CA", , geoCountryUnitedStates)(1))

rs.MoveNext

Loop

End With
'Set the route end point
Set oloc = objMap.ActiveRoute.Waypoints.Add(objMap.FindAddres sResults("Headquarters Address Goes Here", "Los Angeles", "CA", "90031")(1))
objMap.ActiveRoute.Waypoints.Optimize
objMap.ActiveRoute.Calculate

Else
MsgBox "You must enter an address and job code."
DoCmd.Close acForm, "Map Today's Route"
End If

End Sub
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
access, automation, form, mappoint


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/mappoint-automation-access-form-6419.html

Posted By For Type Date
Using MapPoint from Word, Access and Excel - MapPoint Articles - MP2K Magazine This thread Refback 09-26-2007 11:38 PM
MapPoint: Autoroute 2008 This thread Refback 09-26-2007 01:19 AM
MapPoint Download - MP2K Magazine This thread Refback 09-26-2007 12:11 AM
The Magazine for MapPoint - MP2K Magazine This thread Refback 09-25-2007 08:23 PM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Using mappoint automation in .NET without GUI tsay MapPoint 2006/2009 Discussion 2 06-02-2007 05:26 AM
Mappoint and Access with ActiveX On A Form jpateusa MapPoint 2006/2009 Discussion 4 01-30-2007 11:19 PM
Problem using PopUp property in Access Form PMACAFEE MapPoint 2006/2009 Discussion 4 11-12-2006 10:45 PM
MapPoint Automation with C/C++ - Part 1 Eric Frost MP2K Magazine Articles 10 09-15-2006 11:01 AM
summary to access form help please nmilne MapPoint 2006/2009 Discussion 3 01-15-2006 04:22 PM


All times are GMT -5. The time now is 04:58 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54