1

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!

4
  • 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
    Commented Jul 26, 2011 at 15:02
  • Yes I've done that. It doesn't appear to make a difference.
    – Mr_Chimp
    Commented Jul 26, 2011 at 15:08
  • What else do you have ticked in the References dialog?
    – James S
    Commented Jul 26, 2011 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
    Commented Jul 26, 2011 at 15:50

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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