Opening another DB in Access Runtime (1 Viewer)

JayAndy

Registered User.
Local time
Today, 19:54
Joined
Jan 13, 2016
Messages
31
Hi

I am using the below code to open another Access Runtime DB

Code:
Dim accapp As Access.Application
Set accapp = New Access.Application
 accapp.OpenCurrentDatabase ("C:\IAS\Txing.accdb")
accapp.Visible = True

"I am getting the error saying Error 429: ActiveX component can't create object"

Can anyone please help with this or know another way to get this to work.

Thanks
J
 

JHB

Have been here a while
Local time
Today, 20:54
Joined
Jun 17, 2012
Messages
7,732
Try below line instead of "Set accapp = New Access.Application"
Code:
    Set accapp = CreateObject("Access.Application")
 

JayAndy

Registered User.
Local time
Today, 19:54
Joined
Jan 13, 2016
Messages
31
Try below line instead of "Set accapp = New Access.Application"
Code:
    Set accapp = CreateObject("Access.Application")

Thanks JHB but still the same problem and error.
 

JHB

Have been here a while
Local time
Today, 20:54
Joined
Jun 17, 2012
Messages
7,732
The code line I gave you works be me.
I've made an example in the attached database, remember to change the below code line to the correct folder and database.
Code:
  appAccess.OpenCurrentDatabase "C:\Access programmer\Test Database.accdb", True
 

Attachments

  • OpenADatabase.accdb
    368 KB · Views: 282

CJ_London

Super Moderator
Staff member
Local time
Today, 19:54
Joined
Feb 19, 2013
Messages
16,723
I suspect

accapp.OpenCurrentDatabase ("C:\IAS\Txing.accdb")

should be

accapp.OpenCurrentDatabase "C:\IAS\Txing.accdb"

but if not, to clarify terminology, you say 'open another Access Runtime DB' but runtime is a version of the access programme, not a db.

Do you mean 'open another db using access runtime'?

Also to be clear, which is the line generating the error? - and to see the code you must be opening with a full version of access.

And also to clarify, which version of access runtime are you using 2007? 2010? and what version was the .accdb generated in?
 

JayAndy

Registered User.
Local time
Today, 19:54
Joined
Jan 13, 2016
Messages
31
Thanks CJ_London

Have tried Removing the () and are still getting the same error.

In answer to your question, sorry, yes; the terminology is wrong. There shouldn't have been a DB.

We are using Access 2016 to build the database and Microsoft Access 2016 Runtime to run it.

It works without any error in the full version, but not in Microsoft Access 2016 Runtime.

Any help would be gratefully appreciated.


I suspect

accapp.OpenCurrentDatabase ("C:\IAS\Txing.accdb")

should be

accapp.OpenCurrentDatabase "C:\IAS\Txing.accdb"

but if not, to clarify terminology, you say 'open another Access Runtime DB' but runtime is a version of the access programme, not a db.

Do you mean 'open another db using access runtime'?

Also to be clear, which is the line generating the error? - and to see the code you must be opening with a full version of access.

And also to clarify, which version of access runtime are you using 2007? 2010? and what version was the .accdb generated in?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 19:54
Joined
Feb 19, 2013
Messages
16,723
in that case I suspect the code you think is the problem, isn't. Unless you have error handling code, runtime does not report errors, it just closes or freezes.

What code is triggered when the other db is opened?

Is there code that follows the opendatabase line which perhaps has an impact on what is supposed to happen after the db is opened?

Suggest put msgboxes before each line of code so you can track how far the code goes before you get the error when running in runtime

Also try changing your development db to .accdr which mimics running in runtime even if you have the full version

Other things - do all your modules have Option Explicit just below the Option Compare Database line at the top of the module? if not, add it in and compile the db and fix any errors you find.
 

JayAndy

Registered User.
Local time
Today, 19:54
Joined
Jan 13, 2016
Messages
31
Thanks Error Handling is in there.

Error l get is Error 429: ActiveX component can't create object

No code on the other DB just opens a display form.

Have put in message boxes and the problem is the above code.

Have Option Explicit to the top and run

Complie runs start through.

in that case I suspect the code you think is the problem, isn't. Unless you have error handling code, runtime does not report errors, it just closes or freezes.

What code is triggered when the other db is opened?

Is there code that follows the opendatabase line which perhaps has an impact on what is supposed to happen after the db is opened?

Suggest put msgboxes before each line of code so you can track how far the code goes before you get the error when running in runtime

Also try changing your development db to .accdr which mimics running in runtime even if you have the full version

Other things - do all your modules have Option Explicit just below the Option Compare Database line at the top of the module? if not, add it in and compile the db and fix any errors you find.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 19:54
Joined
Feb 19, 2013
Messages
16,723
Sorry, I don't have a solution.

I didn't think access was an activex
 

MarkK

bit cruncher
Local time
Today, 11:54
Joined
Mar 17, 2004
Messages
8,199
Maybe you can't open an Access file through automation without the full verion of Access installed on the machine in question.

But what do you need to do? Sometimes I find people are trying to open Access, when if fact they just need to query data out of a Jet/ACE table in a different file. Keep in mind the you can connect to a different file directly from SQL if you need to. Consider...
Code:
SELECT * 
FROM SomeTable IN "C:\IAS\Txing.accdb"
So if you just need to get at some data...
hth
 

ByteMyzer

AWF VIP
Local time
Today, 11:54
Joined
May 3, 2004
Messages
1,409
The issue is in the statement:
Code:
[COLOR="Navy"]Set[/COLOR] accapp = [COLOR="navy"]New[/COLOR] Access.Application
...or:
Code:
[COLOR="navy"]Set[/COLOR] accapp = CreateObject("Access.Application")

The Access.Application object instance can not be created in the Access Runtime VBA environment.
 

Users who are viewing this thread

Top Bottom