MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Programming Question

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 ...


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

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



Click here to register

Reply

 

LinkBack (1) Thread Tools Display Modes
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 06-09-2008
Junior Member
White Belt
 
Join Date: Apr 2008
Posts: 3
Programming Question

Hello there,

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
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 06-10-2008
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
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)
returns null ?
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 06-11-2008
Junior Member
White Belt
 
Join Date: Apr 2008
Posts: 3
Re: Programming Question

Thanks for the reply, I figured it out. It had to do with my SQL string query.
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
programming, question


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/programming-question-7798.html

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

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
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


All times are GMT -5. The time now is 11:07 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