error 7866, can't open the database because it is missing,..

 
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> General Discussions RSS
Next:  Fields "disappear" from table  
Author Message
David McDivitt
External


Since: Jan 20, 2004
Posts: 11



PostPosted: Wed Jun 22, 2005 6:01 pm    Post subject: error 7866, can't open the database because it is missing, o
Archived from groups: microsoft>public>access (more info?)

I am trying to set the current database for the access application object
through code and keep getting the error 7866: Microsoft Access can't open
the database because it is missing, or opened exclusively by another user.

At the start of the code I do the following:
dao.DBEngine.SystemDB =
dao.DBEngine.DefaultUser =
dao.DBEngine.DefaultPassword =
With this I can successfully use the DAO opendatabase method and do stuff.
At another phase I need to create an application object and set the current
database for that object. Open creating the application object the first
thing I do is:
TempApp.DBEngine.SystemDB =
TempApp.DBEngine.DefaultUser =
TempApp.DBEngine.DefaultPassword =

Following this, when I do the opencurrentdatabase method I get the 7866
error. The problem is probably because dbengine is already initialized,
though I have not yet done anything with the application object. Setting the
dbengine values only works before it is initialized. To fix, the values must
be put in an ini file or in the registry, and those values read by
MSAccess.exe when it creates the application object. Can someone tell me how
to do that? Thanks
Back to top
Douglas J. Steele
External


Since: Oct 07, 2003
Posts: 8178



PostPosted: Wed Jun 22, 2005 9:20 pm    Post subject: Re: error 7866, can't open the database because it is missin [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I believe you need to use PrivDBEngine, rather than DBEngine.

Do a Google search of PrivDBEngine for more details.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"David McDivitt" wrote in message

>I am trying to set the current database for the access application object
> through code and keep getting the error 7866: Microsoft Access can't open
> the database because it is missing, or opened exclusively by another user.
>
> At the start of the code I do the following:
> dao.DBEngine.SystemDB =
> dao.DBEngine.DefaultUser =
> dao.DBEngine.DefaultPassword =
> With this I can successfully use the DAO opendatabase method and do stuff.
> At another phase I need to create an application object and set the
> current
> database for that object. Open creating the application object the first
> thing I do is:
> TempApp.DBEngine.SystemDB =
> TempApp.DBEngine.DefaultUser =
> TempApp.DBEngine.DefaultPassword =
>
> Following this, when I do the opencurrentdatabase method I get the 7866
> error. The problem is probably because dbengine is already initialized,
> though I have not yet done anything with the application object. Setting
> the
> dbengine values only works before it is initialized. To fix, the values
> must
> be put in an ini file or in the registry, and those values read by
> MSAccess.exe when it creates the application object. Can someone tell me
> how
> to do that? Thanks
>
>
Back to top
David McDivitt
External


Since: Jan 20, 2004
Posts: 11



PostPosted: Wed Jun 22, 2005 9:20 pm    Post subject: Re: error 7866, can't open the database because it is missin [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

>Subject: Re: error 7866, can't open the database because it is missing, or opened exclusively by another user
>Date: Wed, 22 Jun 2005 17:20:51 -0400
>
>I believe you need to use PrivDBEngine, rather than DBEngine.
>
>Do a Google search of PrivDBEngine for more details.
>
>--
>Doug Steele, Microsoft Access MVP
>http://I.Am/DougSteele
>(no e-mails, please!)
>
>
>
>"David McDivitt" wrote in message
>
>>I am trying to set the current database for the access application object
>> through code and keep getting the error 7866: Microsoft Access can't open
>> the database because it is missing, or opened exclusively by another user.
>>
>> At the start of the code I do the following:
>> dao.DBEngine.SystemDB =
>> dao.DBEngine.DefaultUser =
>> dao.DBEngine.DefaultPassword =
>> With this I can successfully use the DAO opendatabase method and do stuff.
>> At another phase I need to create an application object and set the
>> current
>> database for that object. Open creating the application object the first
>> thing I do is:
>> TempApp.DBEngine.SystemDB =
>> TempApp.DBEngine.DefaultUser =
>> TempApp.DBEngine.DefaultPassword =
>>
>> Following this, when I do the opencurrentdatabase method I get the 7866
>> error. The problem is probably because dbengine is already initialized,
>> though I have not yet done anything with the application object. Setting
>> the
>> dbengine values only works before it is initialized. To fix, the values
>> must
>> be put in an ini file or in the registry, and those values read by
>> MSAccess.exe when it creates the application object. Can someone tell me
>> how
>> to do that? Thanks

Thanks Doug. I will use that when needed from within MSAccess with VBA. It
still does solve the problem with the application object. I found a
Microsoft article saying how to do this:
http://support.microsoft.com/default.aspx?scid=kb;en-us;192919
How To Automate a Secured Access Database Using Visual Basic

I have used the VB createobject function many times, but never used the
getobject function. Code follows:

dao.DBEngine.SystemDB = "wherever"
dao.DBEngine.DefaultUser = "whoever"
dao.DBEngine.DefaultPassword = "whatever"
FileCopy AnalPath & "\" & AnalFile, TempFile
Set TempDB = OpenDatabase(TempFile)
TempDB.Properties.Delete "AllowBypassKey"
'harvest the document names because accessing them fails when done through
application object
For Each doc In TempDB.Containers("Forms").Documents
For Each doc In TempDB.Containers("Reports").Documents
For Each doc In TempDB.Containers("Modules").Documents
For Each tdf In TempDB.TableDefs
For Each qdf In TempDB.QueryDefs
TempDB.Close
Set TempDB = Nothing
a = RegFunGetValue(HKEY_CLASSES_ROOT,
"Access.Application.9\shell\open\command", "", "")
If Left(a, 1) = Chr(34) _
Then
a = Mid(a, 2)
p = InStr(a, Chr(34))
Else
p = InStr(a, " ")
End If
If p = 0 Then p = Len(a) + 1
a = Trim(Left(a, p - 1))
keybd_event VK_SHIFT, 0, 0, 0
Shell """" & a & """ /NOSTARTUP /USER ""whoever"" /PWD ""whatever"" /WRKGRP
""wherever""", vbHide
Set TempApp = GetObject(, "Access.Application.9")
TempApp.OpenCurrentDatabase TempFile

Since I got this working, an open form call fails on occasion. Have to see
why. Other than that works real good.
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> General Discussions All times are: Eastern Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Warning: fopen(): open_basedir restriction in effect. File(/home/adsense_reject.txt) is not within the allowed path(s): (/home/helploc:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/helploc/public_html/Giga/GigaFunctions.php on line 1144

Warning: fopen(/home/adsense_reject.txt): failed to open stream: Operation not permitted in /home/helploc/public_html/Giga/GigaFunctions.php on line 1144

Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/helploc/public_html/Giga/GigaFunctions.php on line 1145

Warning: fclose() expects parameter 1 to be resource, boolean given in /home/helploc/public_html/Giga/GigaFunctions.php on line 1146