Solved

Calling an ActiveX DLL with form from MSAccess

Posted on 1998-10-08
11
281 Views
Last Modified: 2008-02-20
I have created an Activex DLL which includes a non interactive form - always on top' (display only). I am trying to call the dll in order to display the form, however, access is giving me an error that states "Run-time Error 406 Non-modal forms cannot be displayed in this host application from ActiveX DLL, ActiveX Control, or Property Page."

Is there a way to invoke this ActiveX by getting aroung the modal requirement of MSAccess?  If so, how can I do it?
0
Comment
Question by:dhoule
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
11 Comments
 
LVL 2

Expert Comment

by:mkmccreary
ID: 1438945
This is straight from the mouth of Microsoft.

Modeless Forms
You cannot use modeless forms in some containers, including Internet Explorer, when the server is in-process. If you attempt to use a non-modal form, the following error may be received:


   "Run-time error '406':  Non-modal forms cannot be displayed in
   this host application from an ActiveX DLL, ActiveX Control or
   Property Page."

To avoid this problem, you can code all of your forms to open as modal (being aware of the issues stated above) or you can test for the behavior of the container, using the App object, before opening the form:

   If App.NonModalAllowed Then
      frmModeless.Show vbModeless
   Else
      frmModeless.Show vbModal
   End If

If you do use modeless forms, users will be able navigate away from your ActiveX document and the form will drop to the background if navigation takes place.
Unlike modal forms, modeless forms will appear in the Windows TaskBar if the ShowInTaskBar property is set to true.

0
 
LVL 3

Expert Comment

by:TheAnswerMan
ID: 1438946
Make the Form modal

Form1.show vbmodal
0
 

Author Comment

by:dhoule
ID: 1438947
I understand that the fix is simply to make the form modal, but this is not my desired behaviour.  I wish to be able to pop up an 'always on top' window even if Access is minimized.  There is a certain level of interaction I need with this window..i.e.) sending it a message to display.

Is there a way to do this?  Perhaps by adding a level of indirection?


0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:mkmccreary
ID: 1438948
Does it have to be an ActiveX DLL (In-Process Server).  I think you may be able to do it with an ActiveX EXE (Out-of-Process Server).  If you can make it out of process, let me know if you want to do this and I will see about generating some code.

Later,
Martin

0
 
LVL 3

Accepted Solution

by:
TheAnswerMan earned 100 total points
ID: 1438949
Pop up a window.. then use the SetWindowPos API call to
set it as the Topmost window.  It will remain <on top> after you minimize access.  
0
 

Author Comment

by:dhoule
ID: 1438950
Ok this is an example of what I am trying to do... I would like a VB application which is defined as 'always on top' (which I can already do), that includes a form in it.  On this form is a text box that is populated by calls sent from an MSAccess database application.  I have successfully created both sides of the program...but I got the error that was stated in the first message from me...IF I do make the form in the VB application modal, the error goes away, BUT the desired behaviour is lost...i.e) if the MS Access application is minimized, the VB app is as well (obviously since it is modal)...

I am not sure an ActiveX EXE would solve this since it states it in the original error that I have received, unless there is something that I am not aware of...


0
 
LVL 3

Expert Comment

by:TheAnswerMan
ID: 1438951
since it it non interactive.. you could Shell() to it...
and include the SetWindowPos in it.
0
 
LVL 2

Expert Comment

by:mkmccreary
ID: 1438952
My comment above from Microsoft says that forms can't be modeless in in-process servers.  That leads me to believe that if you make it an Out of Process server (an ActiveX Exe) that it should work.  I haven't had time to test it, but it might not be to difficult for you since you already have the source.  Give it a shot, it couldn't hurt.

Later,
Martin
0
 

Author Comment

by:dhoule
ID: 1438953
I was able to acheive the objective by using the ActiveX EXE (thanks), is there anything I generally need to worry about with regards to memory?
0
 
LVL 2

Expert Comment

by:mkmccreary
ID: 1438954
I haven't heard of any severe memory leaks in dealing with ActiveX EXEs.  Just be sure to clean up after yourself.

Later,
Martin

0
 

Author Comment

by:dhoule
ID: 1438955
I was able to acheive the objective by using the ActiveX EXE (thanks), is there anything I generally need to worry about with regards to memory?
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to debug this code 7 65
Sending a email via excel using vba 6 109
vb6, excel Run-time error 1004 method 'close' of object 'workbooks' failed 7 66
TT Auto Dashboard 13 100
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

740 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