Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm kind of new to VB and DAO so please bear with me on this! I'm not sure if this belongs in gis.se or stackoverflow.

I am trying to embed a simple MapInfo map in an Access form based on the code provided in the MapInfo user guide. It seems I've fallen at the first hurdle. So far I have this:

Dim mi As Object 
Private Sub Form_Open(Cancel As Integer) 
    Set mi = CreateObject("MapInfo.Application") 
    MsgBox (mi) 
    mi.do "Set Application Window " & Form1.Hwnd 
    mi.do "Set Next Document Parent " & Form1.Hwnd & " Style 1" 
    mi.do "Open Table ""World"" Interactive Map From World" 
    mi.RunMenuCommand 1702 
    mi.do "Create Menu ""MapperShortcut"" ID 17 As ""(-"" " 
End Sub 

I am getting runtime error 424 "object required" on this line:

mi.do "Set Application Window " & Form1.Hwnd

The MsgBox outputs "MapInfo Professional" which leads me to believe that the CreateObject command has worked successfully. However if I comment out the problem line I get the same error on the next line. Therefore I assume that the mi variable isn't correctly set up.

Can anybody shed any light on this?

Are there any good resources on line for MapInfo integrated mapping?

Thanks in advance!

share|improve this question
    
Have you added the MapInfo reference in the VBA window in Access? Go to Tools > References. It should be called something like MapInfo x.xx OLE Automation Type Library (where x.xx is the version number of MapInfo)? –  James S Jul 26 '11 at 15:02
    
Yes I've done that. It doesn't appear to make a difference. –  Mr_Chimp Jul 26 '11 at 15:08
    
What else do you have ticked in the References dialog? –  James S Jul 26 '11 at 15:21
    
Visual basic for Applications, MS Access 11.0 Object Library, OLE Automation, MS DAO 3.6 Object Library and MS ActiveX Data Objects 2.1 Library –  Mr_Chimp Jul 26 '11 at 15:50
add comment

1 Answer 1

up vote 0 down vote accepted

I found my answer on the MapInfo Google Group:

I just tested this myself and got the same error. Then I noticed that under the MS Access Class Objects list (usually top left pane in the Visual Basic window) my 'Form1' was actually called 'Form_Form1'. Try using that instead; worked for me! HTH, Tom Bacon

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.