none
Access 2010 runtime error on CreateObject(“Access.Application”)

    Question

  • I have a MDB (2000 file format) with code to open another mdb file while closing the current one using the Access.Application object which works with full version of Access (MS Access 2003 +) but with the Access 2010 runtime I am getting the error: "Access runtime activeX component can't create object".
        Sub OpenWithLowerSecurity(FullPath As String)
        On Error GoTo Err_Sub
        'Opens MDB File With Low Security. Works with Access 2003 and earlier
        
        Dim accessApp As Object
        Set accessApp = CreateObject("Access.Application")
        accessApp.AutomationSecurity = 1 'Low Security
        accessApp.OpenCurrentDatabase (FullPath)
        accessApp.Visible = True
        accessApp.UserControl = True
        
        accessApp.Run "Form1"
    
        ShowWindow accessApp.hWndAccessApp, 3   'Maximizes Window
        
        accessApp.Forms("Form1").SetFocus
        
        'CloseCurrentDatabase
        Set accessApp = Nothing
        DoCmd.Close
        
        Exit_Sub:
            Exit Sub
        
        Err_Sub:
            MsgBox Err.Description
            Resume Exit_Sub
        End Sub
    


    Is there an alternate object compatible with the Access runtime I can use with the same methods used in my function?
    Wednesday, November 09, 2011 2:57 PM

Answers

All replies

  • Rick131 wrote:
    > I have a MDB (2000 file format) with code to open another mdb file
    >    while closing the current one using the Access.Application object
    >    which works with full version of Access (MS Access 2003 +) but
    >    with the Access 2010 runtime I am getting the error: "Access
    > runtime activeX component can't create object".
    > ...
    >    Set accessApp = CreateObject("Access.Application")
    > ...
    > Is there an alternate object compatible with the Access runtime I can
    > use with the same methods used in my function?
     
    It's a known restriction that with the runtime you can't use
    CreateObject to open another instance of Access.
     
    The usual workaround is to open the other file with Shell()
    and then use GetObject(). Have a look at the example in the
    section "Run-Time Version of Microsoft Access" of this kb article:
     
    --
    cu
    Karl
    *********
    Access-FAQ (German/Italian): http://www.donkarl.com
     
     
     
    Wednesday, November 09, 2011 3:06 PM
  • Hello Rick131,

    Rick131 wrote:

    I have a MDB (2000 file format) with code to open another mdb file while closing the current one using the Access.Application object which works with full version of Access (MS Access 2003 +) but with the Access 2010 runtime I am getting the error: "Access runtime activeX component can't create object".

    ...

    http://support.microsoft.com/kb/295179/en-us

    HTH
    Gunter


    Access FAQ: http://www.donkarl.com

          http://www.avenius.com - http://www.AccessRibbon.com
    http://www.ribboncreator.com - http://www.ribboncreator2010.com

    • Marked as answer by Rick131 Wednesday, November 09, 2011 7:33 PM
    Wednesday, November 09, 2011 3:18 PM
  • Hello Rick131,

    ...

    http://support.microsoft.com/kb/295179/en-us

    HTH
    Gunter


     

    According to that knowledgebase article, I can use CreatObject, just not "Access.Application". Correct?

    Is there a way to tell if the mdb is being run on an official Access 2003+ application or from a runtime?

    Wednesday, November 09, 2011 3:41 PM
  • Rick131 wrote:
    > I have a MDB (2000 file format) with code to open another mdb file
    >    while closing the current one using the Access.Application object
    >    which works with full version of Access (MS Access 2003 +) but
    >    with the Access 2010 runtime I am getting the error: "Access
    > runtime activeX component can't create object".
    > ...
    >    Set accessApp = CreateObject("Access.Application")
    > ...
    > Is there an alternate object compatible with the Access runtime I can
    > use with the same methods used in my function?
     
    It's a known restriction that with the runtime you can't use
    CreateObject to open another instance of Access.
     
    The usual workaround is to open the other file with Shell()
    and then use GetObject(). Have a look at the example in the
    section "Run-Time Version of Microsoft Access" of this kb article:
     
    --
    cu
    Karl
    *********
    Access-FAQ (German/Italian): http://www.donkarl.com
     

    Using the ShellWait API I am using the following code, but it is not opening:

    ShellWait FullPath, vbMaximizedFocus

    Wednesday, November 09, 2011 4:16 PM
  • Rick131 wrote:
    >  Hello Rick131,
    >  ...
    >
    > According to that knowledgebase article, I can use CreatObject, just
    > not "Access.Application". Correct?
     
    No. The article is stating clearly:
     
    "The CreateObject call is not supported in the run-time environment..."
     
    > Is there a way to tell if the mdb is being run on an official Access
    > 2003+ application or from a runtime?
     
    You can use
     
    Syscmd(acSysCmdRuntime)
     
    to determine whether the current db runs in a runtime environment.
     
    --
    cu
    Karl
    *********
    Access-FAQ (German/Italian): http://www.donkarl.com
     
     
     
    Wednesday, November 09, 2011 4:29 PM
  • Rick131 wrote:
    > ...
    >  The usual workaround is to open the other file with Shell()
    >  and then use GetObject(). Have a look at the example in the
    >  section "Run-Time Version of Microsoft Access" of this kb article:
    > ...
    > Using the ShellWait API I am using the following code, but it is not
    > opening:
    >
    > ShellWait FullPath, vbMaximizedFocus
     
    What do you pass as FullPath here?
    I didn't try it with the runtime but in general:
     
    If you use one of the typical ShellWait codes like
    the CreateProcess API function. That's quite different from using
    the Shell command of VBA as suggested in the kb article.
    Did you already try that?
     
    --
    cu
    Karl
    *********
    Access-FAQ (German/Italian): http://www.donkarl.com
     
     
     
    Wednesday, November 09, 2011 4:48 PM
  • I ask, because I have used the following in my VBA code and running with the runtime does NOT produce the error: CreateObject("ADODB.Recordset"), CreateObject("ADODB.Connection"), and CreateObject("Word.Application").

    Wednesday, November 09, 2011 4:54 PM
  • I am using that exact ShellWait  API. The full path includes the full path and filename of the mdb file, Ex. "c:\somefolder\myfile.mdb"

    I have tried the following:

    ShellWait """" & FullPath & """", vbMaximizedFocus 'Produces no error messages nor opens mdb.
    Shell FullPath, vbHide 'Produces the error: "Invalid procedure call or argument"
    Shell "run """ & FullPath & """", vbMaximizedFocus 'Produces the error: "File not found"
    Shell "start """ & FullPath & """", vbMaximizedFocus 'Produces the error: "File not found"
    Shell "start FullPath, vbMaximizedFocus" 'Produces the error: "File not found"
    

    I notice that with the native Shell command I believe I have to specify the msaccess.exe path name before the file I want to execute, but how can I make it a bit more universal so it would work with Access 2003+ and the be compatible with the runtime.

    Wednesday, November 09, 2011 6:09 PM
  • Hello Rick131,

    Rick131 wrote:

    I am using that exact ShellWait  API. The full path includes the full path and filename of the mdb file, Ex. "c:\somefolder\myfile.mdb"

    shell needs the fullpath to msaccess.exe and the path with mdb.

    HTH
    Gunter


    Access FAQ: http://www.donkarl.com

          http://www.avenius.com - http://www.AccessRibbon.com
    http://www.ribboncreator.com - http://www.ribboncreator2010.com

    Wednesday, November 09, 2011 6:25 PM
  • Hello Rick131,

    shell needs the fullpath to msaccess.exe and the path with mdb.

    HTH
    Gunter

     

    What exactly do you mean?

    Wednesday, November 09, 2011 6:42 PM
  • Hello Rick131,

    Rick131 wrote:

    shell needs the fullpath to msaccess.exe and the path with mdb.

    What exactly do you mean?

    From  http://support.microsoft.com/kb/210132/en-us "Run-Time Version of Microsoft Access"...

    x = Shell("c:\myapp\Office\msaccess.exe " &_
    Chr$(34) & strDBName & Chr$(34) & _
    "/Runtime /Wrkgrp " & Chr$(34) & _
    "c:\myapp\system.mdw" & Chr$(34))

    HTH
    Gunter


    Access FAQ: http://www.donkarl.com

          http://www.avenius.com - http://www.AccessRibbon.com
    http://www.ribboncreator.com - http://www.ribboncreator2010.com

    Wednesday, November 09, 2011 6:48 PM
  • Rick131 wrote:
    > ...The full path includes the full
    > path and filename of the mdb file, Ex. "c:\somefolder\myfile.mdb"
    >
    > I have tried the following:
    > ...
    > Shell FullPath, vbHide 'Produces the error: "Invalid procedure call
    > or argument"
    > ...
    > I notice that with the native Shell command I believe I have to
    > specify the msaccess.exe path name before the file I want to execute,
    > but how can I make it a bit more universal so it would work with
    > Access 2003+ and the be compatible with the runtime.
     
    This should work:
     
    Shell _
    Chr$(34) & SysCmd(acSysCmdAccessDir) & "MSAccess.exe" & Chr$(34) _
    & " " & Chr$(34) & FullPath & Chr$(34)
     
    --
    cu
    Karl
    *********
    Access-FAQ (German/Italian): http://www.donkarl.com
     
     
     
     
    Wednesday, November 09, 2011 6:50 PM
  • Now the only problem would be in the case of more than 1 extra Access instance.

    In that case, with GetObject, you can't distinguish between the two different instances.

    I believe it will reference the last opened instance....not sure about that however.

     

    Wednesday, November 09, 2011 9:38 PM
  • The issue is not that runtime doesn't support creatobject command (it does), but that runtime access cannot be created using create object. In fact the instance does get created but then the runtime says hey no file and shutdown. So the "real" problem is runtime shutting down right after it been launched. I'd u could pass filename with create object then this could work but u can't.

    Runtime works this way since no GUI is presented when launched and users thus wouldn't be able to shut down msaccess.exe except via task manager. So runtime simply shuts down if no file name passed since without filename it has nothing to do.

    Thursday, November 10, 2011 11:38 AM