Community of VE/MapPoint Users and Developers
This is a discussion on Programming Question within the Development forums, part of the MapPoint 2006/2009 Discussion category; Hello there, I am relatively new to programming with MapPoint. I am developing a huge salesforce mapping software which will ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Programming Question I am relatively new to programming with MapPoint. I am developing a huge salesforce mapping software which will pick up its coordinated from a query in MS Access. So far following is the code which I have. As you can see I am passing a sql string to the rstProps recordset. When I run the map. It comes out as blanks with no addresses coordinated. Can someone lead to where I am going wrong in the code? All help and support will be appreciated. _______________________________________ Option Compare Database 'Use database order for string comparisons Option Explicit Private Const WS_CAPTION = &HC00000 Dim strSQLStart As String Dim strSQLFrom As String Dim strSQLWhere As String Dim strSQL As String Dim lngLen As Long Dim strSQLEnd As String Private Sub cbo_mod_Change() Me.cbo_fldesc.RowSource = "SELECT DISTINCT [Func Loc + MCB].FunctLocDescrip, [Modality Map].Modality FROM ([Func Loc + MCB] INNER JOIN [Functional Locations IL03] ON [Func Loc + MCB].[Functional location]=[Functional Locations IL03].[Functional location]) INNER JOIN [Modality Map] ON [Functional Locations IL03].[Cost ctr]=[Modality Map].[Cost ctr] WHERE ((([Modality Map].Modality)=Forms![frmMain]!cbo_mod)); " End Sub Private Sub ChangeRecordSource() On Error Resume Next strSQLStart = "SELECT qry_map_data.[List name]" strSQLStart = strSQLStart & " , qry_map_data.Type" strSQLStart = strSQLStart & " , qry_map_data.Modality" strSQLStart = strSQLStart & " , qry_map_data.FunctLocDescrip" strSQLStart = strSQLStart & " , qry_map_data.RG" strSQLFrom = " From qry_map_data" If Not IsNull(Me.cbo_client) Then strSQLWhere = "([qry_map_data].[list name] = """ & _ Me.cbo_client & """) AND " End If If Not IsNull(Me.cbo_mod) Then strSQLWhere = strSQLWhere & "([qry_map_data].[Modality] = """ & _ Me.cbo_mod & """) AND " End If If Not IsNull(Me.cbo_fldesc) Then strSQLWhere = strSQLWhere & "([qry_map_data].[FunctLocDescrip] = """ & _ Me.cbo_fldesc & """) AND " End If If Not IsNull(Me.cbo_type) Then strSQLWhere = strSQLWhere & "([qry_map_data].[Type] = """ & _ Me.cbo_type & """) AND " End If lngLen = Len(strSQLWhere) - 5 'Without trailing " AND " If lngLen > 0 Then strSQLWhere = " WHERE " & Left$(strSQLWhere, lngLen) End If strSQLEnd = ";" strSQL = strSQLStart & strSQLFrom & strSQLWhere strSQLWhere = "" Me.fsubProperties.Form.RecordSource = strSQL If Err = 2501 Then Err.Clear End Sub Private Sub Command12_Click() ChangeRecordSource End Sub Sub MapSelectedProperties() 'Map the selected properties On Error GoTo MapSelectedProperties_Err_Exit Dim db As Database Dim rstProps As Recordset Dim objLoc As MapPoint.Location Dim objMap As MapPoint.Map Dim objPushpin As MapPoint.Pushpin Dim strMsg As String Dim i As Integer i = 0 Set db = CurrentDb() 'Load the selected properties into a recordset Set rstProps = db.OpenRecordset(strSQL) 'Make sure at least one property was selected If rstProps.RecordCount > 0 Then 'Load Map If LoadMap() Then 'Open the form containing the map FormOpen "frmMap" Set objMap = gappMP.ActiveMap 'Place a pushpin on the map for each selected property While Not rstProps.EOF i = i + 1 Set objLoc = objMap.FindAddressResults(rstProps!Street, rstProps!City, rstProps!Rg, rstProps![Postal code])(1) Set objPushpin = objMap.AddPushpin(objLoc, rstProps![List name]) objPushpin.Name = CStr(i) objPushpin.BalloonState = geoDisplayBalloon objPushpin.Symbol = 77 objPushpin.Highlight = True rstProps.MoveNext Wend 'Show all pushpins on the map display objMap.DataSets.ZoomTo Else strMsg = "Unable to load map." MsgBox strMsg, vbOKOnly + vbExclamation, APP_NAME End If Else strMsg = "No properties selected." MsgBox strMsg, vbOKOnly + vbExclamation, APP_NAME End If MapSelectedProperties_Err_Exit: On Error Resume Next Set objPushpin = Nothing Set objLoc = Nothing Set objMap = Nothing rstProps.Close db.Close Exit Sub MapSelectedProperties_Err: Resume MapSelectedProperties_Err_Exit End Sub Function LoadMap() As Boolean 'Create an instance of MapPoint On Error GoTo LoadMap_Err Set gappMP = CreateObject("MapPoint.Application") gappMP.Visible = False gappMP.PaneState = geoPaneNone 'Get the handle of the MapPoint Window ghwndMP = FindWindow(vbNullString, "Map - Microsoft MapPoint North America") 'Remove MapPoint Title Bar FlipBit ghwndMP, WS_CAPTION, False LoadMap = True LoadMap_Err_Exit: Exit Function LoadMap_Err: LoadMap = False GoTo LoadMap_Err_Exit End Function Private Sub Command25_Click() MapSelectedProperties End Sub |
| |||
| Re: Programming Question
Hi, Can you be more specific in your description please? Do you mean that the line: Code: objMap.FindAddressResults(rstProps!Street, rstProps!City, rstProps!Rg, rstProps![Postal code])(1)
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| programming, question |
| ||||
| Posted By | For | Type | Date | |
| The Magazine for MapPoint - MP2K Magazine | This thread | Refback | 06-09-2008 12:15 PM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Simple Programming Question | roadwarrior | Development | 1 | 02-18-2008 09:02 AM |
| Ambiguous messages ( programming or not programming? ) | Mohamed | MapPoint 2006/2009 Discussion | 1 | 06-13-2006 04:35 PM |
| Pushpin programming question | Anonymous | MapPoint 2006/2009 Discussion | 2 | 07-16-2004 04:08 PM |
| How to programming using VC6.0 | confach | MapPoint 2006/2009 Discussion | 4 | 03-01-2004 06:25 AM |
| Programming in VB.Net | Anonymous | MapPoint 2006/2009 Discussion | 3 | 12-01-2003 10:52 AM |