spacer2 1_1 1_2
 The MP2K Update!
Front Cover
What's New
Sample Data
MapPoint 2013
Press Releases
MapPoint Forums
Link to MP2Kmag
Wish List
MapPoint Trial
 Earlier Content
Past News Items
Past What's New Announcements

MapPoint 2013

Programming MapPoint in .NET

MapPoint Book

  Spatial Community
SVG Tutorials

Map Visitors


Home Locator Sample Application

John Washenberger writes, "In the spirit of the MDB 'Circus' Contest, the application I have submitted could be considered a 'three-ring extravaganza'."

The application is a simple Home Locator. Download it here. It contains a single table of properties (i.e., homes). Each property includes address information and a sale price. When the application is opened, the startup form displays the properties sorted by price in descending order. A simply query interface is included on the form to allow the user to display properties within a price range. A checkbox is included for each displayed property to allow the user to select properties that can subsequently be displayed on a map that can be output to a report.

In this article, I will demonstrate some interesting approaches to using MapPoint within an Access application. I will not go into any detail on the Access specific code itself. Instead I’ll focus on using MapPoint from within the Access application offering a couple alternatives to conventional methods.

For example, the application does not use the MapPoint OCX control. It uses an instance of MapPoint that is “pulled” into an Access form. An advantage of doing this is that all the MapPoint functionality is available which is not true when using the OCX. For example, the Print Dialog is not accessible to an application using the OCX. Instead the developer must write code using the PrintOut method to offer the features included in the Print Dialog.

Another approach that may seem a bit unusual is used to generate a report that includes a map. When the report is opened, the application first saves the map as a web page and then strips out the GIF file that is used in the Access report.

Let’s first take a look at using MapPoint in Access without using the OCX. This can be done using the Windows API functions that are prototyped in “basMain” of the application. Once an instance of MapPoint is opened using CreateObject, the windows handle to MapPoint can be acquired using the FindWindow API call. This is demonstrated in Function LoadMap() which can be found in the code behind form “frmMain”. The handle is stored in a global variable and is subsequently used when the Map form “frmMap” is opened. The Map form contains a subform call “fsubMap”. In the On_Load event of the subform, the SetParent API call is made passing in the MapPoint windows handle and the handle to the subform. This call forces the MapPoint application to be displayed with the subform. Notice also in the subform’s Resize_Event that the MapPoint WindowState is maximized. This forces the MapPoint to retain the size of the subform.

Now it appears that MapPoint is built into Access and all the functionality of MapPoint is at the user’s fingertips.

For the most part, that is how it works. Some of the details are not described here but should be fairly clear after reviewing the code.

Once the map is opened, a report can be generated. When the “Generate Report” command button is clicked, the SaveAs method (which is not available when using the OCX) is used to save the map as a web page to the directory where the Home Locator application is located. The generated directory contains the map in GIF format. The application copies the GIF file to “map.gif” in the Home Locator directory before deleting the directory created when the SaveAs method was executed. Now that the map exists in GIF format at a predefined location, it can be used in a report. In this application the report’s picture is set to reference the GIF file in the report’s Report_Open event when the report is opened. That’s it. Take a look at the report’s Picture Alignment property to reposition the map on the report.

More times than not there are multiple ways to accomplish a given task when developing Windows applications. This holds true when developing with MapPoint. Hopefully, this article has given you some ideas on how to use MapPoint in developing integrated solutions.

By the way, there is additional code in the application that was not described here that may be helpful to you. Please feel free to send me your comments or any enhancements you may have.


Discuss this story in the forum.

Author: John Washenberger
Email: jwash(AT)
John is a Software Development Consultant for SeaDak Solutions, Inc. located on Bainbridge Island, WA which specializes in developing Microsoft integrated office and database solutions.

MP2Kmag Internet

 Recent Discussion
Browse GIS books and periodicals
Find a MapPoint Partner or Consultant
Real Estate Columbia Homes for Sale by Owner

Want Your Site To Appear Here?

   © 1999-2012 MP2K. Questions and comments to:
  Microsoft and MapPoint 2002/2004/2006/2009/2010/2011/2013 are either trademarks or registered trademarks of Microsoft.