Previous testing was with a very simple A2003 file containing just one form with a Map control. Have now tried MW with an application that I am developing, and that contains numerous other controls. The Map control is contained within an Access Tab control. Here is the Load event for the form that contains the Map control. There is nothing else in the app that pertains to the Map control
Private Sub Form_Load()
Dim gs As New GlobalSettings
gs.ApplicationCallback = New MwCallback
axMap.TileProvider = tkTileProvider.OpenStreetMap
iLayerhandle = axMap.AddLayerFromFilename("d:\\FromDBF.shp", tkFileOpenStrategy.fosAutoDetect, True)
' axMap.Projection = tkMapProjection.PROJECTION_WGS84
End Sub
There is a Class module to define Global settings. The above code works perfectly in my original testing MDB, but when I uncomment the Projection statement, it consistently crashes A2003.
Comments: ** Comment from web user: jacksonmacd **
Using the map control on forms in older software such as Microsoft Access 2003 or 2010 may cause the host program to crash, however, you can workaround this problem by placing the map control inside a frame control on the form. Some points to consider:
- the Frame control is accessible via the "Other Controls" button on the Access toolbox in A2003 and from the More button in the Design group in A2010
- add the frame to the form, then right-click inside the Frame control in Design mode and choose Frame Object > Edit from the context menu
- if the Frame's toolbox is not visible, right-click on the Frame and choose Toolbox...
- right-click inside the toolbox and choose Additional Controls...
- find Map Control in the list and check the checkbox to add Mapwindow to the suite of controls that can be added to the frame
- add the map control to the frame
- The frame control should be placed directly onto the form's design surface. Placing a map control inside a frame control that is inside a tab control will cause Access to crash.
- In the Design View, the map control may be invisible within the frame until you select the frame control and choose Edit
- clicking inside the frame control may cause Access to crash, however, clicking and dragging the frame control does not cause Access to crash
- VBA code must refer to the map control through the frame control e.g.
Dim axMap As MapWinGIS.Map
Set axMap = Frame1.Map1
axMap.Projection = PROJECTION_GOOGLE_MERCATOR
--
------------------------------------
Jack