Resetting the DBEngine.SystemDB after creating an Access application object 
Author Message
 Resetting the DBEngine.SystemDB after creating an Access application object

We're trying to reset the DBEngine.SystemDB after using CreateObject() to
create an Access application object. Despite what the documentation says,
any attempts to change this value don't stick. Further, it doesn't even
raise an error if an invalid file name is used.  We're installing our
application at sites that already use Access and we don't want to interfere
with existing apps by forcing them to keep switching back and forth between
our workgroup file and their own. Our app is launched through a shell
command from a VB executable. In the shell command, we use a command line
switch to use our workgroup file. However, our app will create Access
application objects for handling things like imports and exports and using
CreateObject() uses the current workgroup file, which apparently can't be
changed. Any ideas???

Brook



Thu, 21 Jun 2001 03:00:00 GMT  
 Resetting the DBEngine.SystemDB after creating an Access application object
Brook,

There's a registry key for SystemDB, you could probably change that
before and after working with Access object. Or take a look at
PrivDBEngine (there's a description at  home.att.net/~dashish, also
see some threads on Dejanews). HTH

Dimitri

Quote:

> We're trying to reset the DBEngine.SystemDB after using CreateObject() to
> create an Access application object. Despite what the documentation says,
> any attempts to change this value don't stick. Further, it doesn't even
> raise an error if an invalid file name is used.  We're installing our
> application at sites that already use Access and we don't want to interfere
> with existing apps by forcing them to keep switching back and forth between
> our workgroup file and their own. Our app is launched through a shell
> command from a VB executable. In the shell command, we use a command line
> switch to use our workgroup file. However, our app will create Access
> application objects for handling things like imports and exports and using
> CreateObject() uses the current workgroup file, which apparently can't be
> changed. Any ideas???

> Brook



Thu, 21 Jun 2001 03:00:00 GMT  
 Resetting the DBEngine.SystemDB after creating an Access application object
In VB, your code can  be running before the Jet engine is
instantiated. But in Access, Jet is already running and it is not
possible to change the SystemDB midstream. SystemDB can only be set
prior to firing up a new instance of Jet.

To get around this, DAO includes an undocumented object called
PrivDBEngine that can be used to create a new instance of Jet with its
own new SystemDB, like this:

    Dim dbe As PrivDBEngine
    Dim wrk As Workspace
    Dim dbs As Database

    Set dbe = New PrivDBEngine
    dbe.SystemDB = "C:\MyPath\MySystem.mdw"
    dbe.DefaultUser = "MyUser"
    dbe.DefaultPassword = "MyUserPwd"
    Set wrk = dbe.Workspaces(0)
    Set dbs = wrk.OpenDatabase _
      ("C:\MyPath\MyDatabase.mdb")

But this will only help if you are performing DAO operations. If you
need another instance of Access, you might want to use Shell and set
the wrkgrp switch, and then use GetObject to set a reference to that
instance.

 -- Andy

Quote:

>We're trying to reset the DBEngine.SystemDB after using CreateObject() to
>create an Access application object. Despite what the documentation says,
>any attempts to change this value don't stick. Further, it doesn't even
>raise an error if an invalid file name is used.  We're installing our
>application at sites that already use Access and we don't want to interfere
>with existing apps by forcing them to keep switching back and forth between
>our workgroup file and their own. Our app is launched through a shell
>command from a VB executable. In the shell command, we use a command line
>switch to use our workgroup file. However, our app will create Access
>application objects for handling things like imports and exports and using
>CreateObject() uses the current workgroup file, which apparently can't be
>changed. Any ideas???

>Brook



Thu, 21 Jun 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. DBEngine & SystemDB property

2. SystemDB property of DBEngine through DAO

3. DBEngine.SystemDB can't be assigned

4. DAO#4 DBEngine.SystemDB - can you refresh it?

5. DAO #4 DBEngine.SystemDB (Revisited)

6. OLE Error 0x80040112 when creating DBEngine object

7. OLE Error 0x80040112 when creating DBEngine object

8. How to reset DBEngine?

9. Creating a query in Access from Excel: ref to DBEngine(0) fails

10. accessing another application's application object

11. vb30 to vb40 port with error 3173 SystemDB access problem

12. Access Forms collection, App object or Global object of the Parent application

 

 
Powered by phpBB® Forum Software