Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble With Controls 1

Status
Not open for further replies.

JPeters

MIS
Jul 25, 2001
423
US
Getting the error message, "There is no object in this control."

I'm trying to use the Map Point 2002 Control, and it's not working - rather frustrating. I have MP2k referenced ... I've got the control registered ... and I have the Map Point ACtiveX Box sitting in my Access form... yet when I start the form I get the dang error.

I read this thread:
"There is no object in this control."
thread181-8719

And I can't seem to get anywhere... Can anyone help or explain how to do this. Does this need to be some Global code or what? This problem has been plaguing me for about 3 days now... I appreciate it. Thanks guys..

-Josh ------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
Josh,

You’ve found a heck of a control to keep track of your buried Bud Kegs, but if this is your chosen method, more power to you. As you are probably finding, the true extollers of Map Pint is dear old MicroSoft. I’ve not yet had to use it and I think if asked to do so, there are a lot of mapping controls out there and I think MS is not, at this point a viable contender. The code below is by Larry Lasandrini. Basically it was the test he used to determine how good or bad Map point is. You can probably tell he was not overly impressed. If you study the example it will certainly tell you how to set it up properly and then make your own determinations.

Good luck.



---- From a previous post of mine located on Google ----

I found some code at MSDN written by Mike Gunderloy. Search MSDN for
the article named "Mappoint 2000: Navigating Microsoft's Mapping Software"

I modified the code so it would point to Northwind Customers table to get a
list of addresses to map. Most addresses fail, but you get the point.

' Determine distances of each office from the home
' location by using the object model directly.
Sub GetDistances1()

Dim objApp As MapPoint.Application
Dim objMap As MapPoint.Map
Dim objLocation As MapPoint.Location
Dim objHomeLocation As MapPoint.Location
Dim rstCust As ADODB.Recordset
Dim sConn As String
Dim sSQL As String

Dim sName As String
Dim sAddress As String
Dim sCity As String
Dim sState As String
Dim sZip As String
Dim lDistance As Long

' Open MapPoint and get a pointer to
' a new blank map.
Set objApp = New MapPoint.Application
Set objMap = objApp.NewMap

' Get a location object for our home location.
sAddress = "1 Microsoft Way"
sCity = "Redmond"
sState = "WA"
sZip = "98052"
Set objHomeLocation = objMap.FindAddress(sAddress, sCity, sState, sZip)

' Open a recordset on the table and loop through it.
sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source="
sConn = sConn & "C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb;"

sSQL = "SELECT CompanyName, Address, City, Region As State, PostalCode As Zip "
sSQL = sSQL & "FROM Customers WHERE Country='USA'"

Set rstCust = New ADODB.Recordset
rstCust.Open sSQL, sConn, adOpenForwardOnly, adLockOptimistic

Do Until rstCust.EOF
sName = CStr(rstCust("CompanyName"))
sAddress = CStr(rstCust("Address"))
' trim the "Apt Num" from end of address
If InStr(1, sAddress, vbCrLf) > 0 Then
sAddress = Left(sAddress, InStr(1, sAddress, vbCrLf) - 2)
End If
sCity = CStr(rstCust("City"))
sState = CStr(rstCust("State"))
sZip = CStr(rstCust("Zip"))

' Locate this entry.
Set objLocation = objMap.FindAddress(sAddress, sCity, sState, sZip)

' Make sure we found something.
If Not objLocation Is Nothing Then
' Find and save the distance.
lDistance = objMap.Distance(objHomeLocation, objLocation)
Debug.Print "Distance from Microsoft " & sName & ": " & lDistance & " miles."
Else
Debug.Print "Distance from Microsoft " & sName & ": (Unknown)"
End If

rstCust.MoveNext
Loop

rstCust.Close
objApp.Quit

Set objApp = Nothing
End sub

Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
Robert,
Okay, after some editing --> I've tested the code. I had something similar to this allready, upon combining them I'm a step closer to what I had wanted to do. What this allows me to do is have MapPoint load up and populate a map
programatically through recordsets in Access.
This is CLOSE to what I want to do, but I need to utilize the ActiveX control and have MapPoint NOT Load up, instead I want a window inside my form (the activeX control) to display the map -> not a full loadup of MP 2k. I'm supposedly able to do this by registering my control (done) selecting the MP 9.0 control from the activeX toolbar, and making a window inside my form ...
Well after doing this the way it says to in my MapPoint for Dummies book, on Microsoft's website, and on (a good mappoint site) .. I'm talking copying and pasting direct code that has worked for them ... it won't work. It gives me the error I listed above in the first post of this thread. And it's driving me crazy. [curse]
THe control is registered (because it appears in my list), I have the CDs right in front of me and I've reinstalled 3 times.... I cannot figure out why it won't work.
You mentioned other Map Controls? What is more user friendly and Access compatable with built in ActiveX controls? I'd really like to sitck with MP2002 cuz my department just purchased 3 licenses for it... Can anyone figure this one out?

-Josh ------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
Update:
Okay ... OCX files are ActiveX Controls. That's their extension. When I remove the MP 2k's Control reference in access and try to re-add it by going to Tools/ActiveX Controls/Register and point it to the MapPointControl.OCX
I get an error saying "This is not a valid ActiveX control" ... Curious... Reinstalled it again - control is listed in Access still.. still not working. Need enlightenment Buddha - please post. ;-) ------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
Josh,

One of these days we're bound to run into each other. For the following information you buy the first two beers. If this gets you close to a solution, you're stuck with dinner,too.

OK. First goto MS Developers Network and find an article called "Mappoint 2000: Navigating Microsoft's Mapping Software" That should give you the nuts and bolts of getting it to work. Then, for bed time reading, Go to MSKB and get article Q236615.

i would have gotten you this stuff earlier, but paying clients get priority; and speaking of paying clients, let me get some more real work done.

Hope this helps you. Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
Robert,
Star for the articles to read. I'll get to that once I finish this little rant - maybe It'll gte some more attention.
A couple of things I should reitterate. The MapPointControl.OCX is an ActiveX Control Object Library that controls the Bound AcitveX Control boxes in a form through VBA (wait what did I just say?) ... In other words -> I reference my Object LIbrary (tools/references) with the MapPointControl.ocx file and that populates the Object Library. I don't add it by registering the .Ocx file as an ACtiveX Control .. . Now with that confusing bit said ... I've made some progress.

Here's something that has been getting to me. MapPoint's help file says that I'm supposd to use the MapPointControl library and not the MapPoint library for control of the ActiveX. Well, In my Object Browser, all i have is MapPoint .. there is no MapPointControl library.. HOWEVER, MapPoint.MapPointControl does exist, but it only contains a very SMALL portion of the methods that MapPoint contains (the help file begs to differ saying that it contains a huge range of methods). ALSO, the help file for MP2002 says that to call the MapPointControl I use (this is a direct copy.paste) (read closely):

'Assume the MappointControl on your form is named "MPC"

Sub Form_Load()

Dim objMap As MappointCtl.Map

'Use the default North American Map
Set objMap = MPC.NewMap(geoMapNorthAmerica)

End Sub

Okay .. several problems here. FIrst off there is no MapPointCtl object library. I only have MapPoint! And I've got that Sub library ... MapPoint.MapPointCONTROL ... no MapPointCtl. HUH? Someone tell Microsoft quickly!
SO when I make the ActiveX Control in the form and then name it MPC, I get this error - Compile ERror: User-defined type not defined. Then the debug button shoots me to the objMap As MapPointCtl.Map ... well this is obvious - there is no MapPointCtl .... so I change it to
Dim objMap As MapPoint.Application and use the MapPoint library, but MapPoint's help file STRONGLY RECOMMENDS that you use the MapPointControl and not the MapPoint.Application when trying to embed MapPoint into your applications... How am I supposed to do that ... I'm lost. I admit I'm a bit embarassed - I really cannot figure this out. Thanks for the replies, Robert. Any luck with that AC97 developers edition license?

-Josh ------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top