Solved

Calculating route using mappoint and microsoft access

Posted on 2008-10-24
7
314 Views
Last Modified: 2013-11-28
Hi Experts,
I have come a long way with this program so far, but I am really stuck now.  Here is the line of code that is throwing an error "method or data member not found"...

objroute.Waypoints.Add objMap.FindAddressResults(rs2("OrigAddress1"), rs2("OrigCity"), rs2("OrigState"), rs2("OrigZip").Item(1))

The rest of the code is below.  Help, please.  Thanks.

Laura :-)
Private Sub cmbRunPSIQuery_Click()

'On Error GoTo Err_cmbRunPSIQuery_Click

    

    

    Dim rs As Recordset

    Dim rs2 As DAO.Recordset

    Dim stDocName As String

    

    Dim oApp As MapPoint.Application

    

    stDocName = "qryTripManifestforPrinttoFilePSIInvoice"

        

    Set oApp = CreateObject("MapPoint.Application")

    

    CurrentDb().Execute "DELETE * FROM tblMapquestMiles"

    Set rs = CurrentDb.OpenRecordset("Select * From tblMapquestMiles")

    Set rs2 = CurrentDb().OpenRecordset("Select * from qryTripManifestforPrinttoFilePSIInvoiceCopy Where VendorID = " & cboVendorID.Value & " and (TripDate >= #" & txtStartDate.Value & "# and TripDate <=#" & txtEndDate.Value & "#)", dbOpenSnapshot)

    

    
 

    Stop

    Do While Not rs2.EOF

    

        Set objMap = oApp.NewMap

        Set objroute = oApp.ActiveMap

        

        'Add route stops and calculate the route

        objroute.Waypoints.Add objMap.FindAddressResults(rs2("OrigAddress1"), rs2("OrigCity"), rs2("OrigState"), rs2("OrigZip").Item(1))

        objroute.Waypoints.Add objMap.FindAddressResults(rs2("DestAddress1"), rs2("DestCity"), rs2("DestState"), rs2("DestZip").Item(1))

        

        objroute.Calculate

        

        rs.AddNew

        rs("TripNumber") = rs2("TripNumber")

        rs("RoundedMiles") = objroute.Distance

        rs.Update

        

        rs2.MoveNext

    Loop

    

    Set rs = Nothing

    Set rs2 = Nothing

    

    oApp.Quit

        

    DoCmd.OpenQuery stDocName, acNormal, acEdit

    

Exit_cmbRunPSIQuery_Click:

    Exit Sub

    

Err_cmbRunPSIQuery_Click:

    MsgBox Err.Description

    Resume Exit_cmbRunPSIQuery_Click:

    

End Sub

Open in new window

0
Comment
Question by:linbayzak
  • 3
  • 3
7 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22804066
linbayzak,

I can't see where you actually declared: objroute

For example:
Dim objroute as XXXX

JeffCoachman
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22804068
... or: objMap
0
 

Author Comment

by:linbayzak
ID: 22812731
No, I didn't declare them.  My boss started this code out as a function.  I'll try to declare them and see what happens. Thanks :-)
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:linbayzak
ID: 22813137
Ok, I declared:
Dim objroute As MapPoint.Route
Dim objMap As MapPoint.Map

and I still get the same error...it always stops on .Item and is grayed out instead of highlighted yellow.  Any ideas what is wrong? Thanks :-)

Laura
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 250 total points
ID: 22819418
linbayzak,

The error basically means that ".Item" is not a member of a certain Object.

I don't know MapPoint VBA, so you you will have to google the statements/keywords for help with the syntax.

JeffCoachman
0
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 250 total points
ID: 22820855
see if this will work

        objroute.Waypoints.Add objMap.FindAddressResults(rs2("OrigAddress1"), rs2("OrigCity"), rs2("OrigState"), rs2("OrigZip")) (1)
        objroute.Waypoints.Add objMap.FindAddressResults(rs2("DestAddress1"), rs2("DestCity"), rs2("DestState"), rs2("DestZip")) (1)
       
0
 

Author Closing Comment

by:linbayzak
ID: 31509834
Hi Experts,

You were right, the object wasn't declared.  Yes, Capricorn1, that line will work, part of the problem was that I had the closing parentheses at the end instead of after OrigZip and DestZip.  At any rate, it is working.  Thanks
Laura
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now