Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


You attempted to open a database ...

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,64391
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> You attempted to open a database ...
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 You attempted to open a database ... - 9/18/2008 10:48:04 PM   
  azizrasul

 

Posts: 2
Score: 0
Joined: 9/18/2008
Status: offline
I have the following VB script which works nearly right to the end.

Set objShell = CreateObject("WScript.Shell")
objShell.Run "K:\Tips\ClickYes.exe -activate"
Set objShell= Nothing
rem OpenDatabase has the following arguments: -
rem OpenDatabase(dbname, options, read-only, connect)
Dim dbs
Dim strDatabaseName
Dim strMacro
strMacro = "mcrTheatreSessionUtilisationandActivity"
strDatabaseName = "\\stg1nas02\Information\Routine\Information Reports\Inpatients\Theatres Performance Audit Front End.mdb"
Set objAccess = CreateObject ("Access.Application")
With objAccess
   'This temporarily changes the macros security to low to avoid messages. Only works with Access 2000 onwards.
   If.syscmd(7) >= 10 Then
.AutomationSecurity = 1
   End if  
   .Visible = True
   Set dbs = .DBEngine.OpenDatabase(strDatabaseName, False)
   .OpenCurrentDatabase strDatabaseName
   .Usercontrol = True
   .DoCmd.RunCommand 10 'acCmdAppMaximize
   .DoCmd.RunMacro strMacro
   .CloseCurrentDatabase
   .Quit
End With
Set objAccess = Nothing
dbs.Close
Set dbs = Nothing
Set objShell = CreateObject("WScript.Shell")
objShell.Run "K:\Tips\ClickYes.exe -suspend"
Set objShell= Nothing

However I get an error 'You attempted to open a database that is already opened exclusively by user 'Admin' on machined 'mymachine'. Try again when the database is available'

_____________________________

Aziz
 
 
Post #: 1
 
 RE: You attempted to open a database ... - 9/19/2008 3:05:23 PM   
  fosterr_2000

 

Posts: 115
Score: 0
Joined: 12/18/2004
From:
Status: offline
Your script seems to work fine.  I have three questions thought.

1. What does the macro do?

2. Have you tried creating a new access database with a simple macro that only does a beep for instance just for script testing?  This is what I did and it works fine.

3. Also maybe try it without the ClickYes.exe lines.


Good luck!

(in reply to azizrasul)
 
 
Post #: 2
 
 RE: You attempted to open a database ... - 9/19/2008 10:08:56 PM   
  azizrasul

 

Posts: 2
Score: 0
Joined: 9/18/2008
Status: offline
By using Set dbs = .DBEngine.OpenDatabase(strDatabaseName, False, True)
it worked.

(in reply to fosterr_2000)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> You attempted to open a database ... Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts