Using non-VBA (VBScript etc) to open Access db in new Access instance (1 Viewer)

Isaac

Lifelong Learner
Local time
Today, 00:09
Joined
Mar 14, 2017
Messages
6,072
I have a machine where an Access db is going to be running all the time, doing some timer/scheduling related things.
Due to code running often, it might be more or less "frozen" at times, in the way that these Office apps freeze while code is running.

During this same time, a client may want to double-click a desktop icon that opens a different Access db, for a different purpose.
If they do this, quite possibly, they will sit there while 'nothing' happens, wondering why Access isn't opening......Because the SAME (SINGLE) Access app instance, is trying to also open their second db.

One way I was hoping to get around this was to use VBScript to open the second db in a new application instance.

But:
Code:
dim accessapp
set accessapp = createobject("access.application")
accessapp.opencurrentdatabase("path to file.accdr")
accessapp.usercontrol=true

....doesn't work for accdr

Is there another solution? I kind of wanted to keep using accdr
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:09
Joined
Feb 19, 2002
Messages
34,462
When a user opens an Access database, it doesn't matter where the database is located, the Access.exe on HIS PC runs and opens the app in memory on HIS PC.

If you want to have a machine that runs Access using a scheduler, NO ONE should be logged into that machine - EVER unless they are doing maintenance.
 

Isaac

Lifelong Learner
Local time
Today, 00:09
Joined
Mar 14, 2017
Messages
6,072
When a user opens an Access database, it doesn't matter where the database is located, the Access.exe on HIS PC runs and opens the app in memory on HIS PC.
Right, agreed. My question is how to open a second instance of the Access application. I normally do this successfully by using a different (non-Access) program to host the code (VBScript, etc), but

opencurrentdatabase doesn't work, for some reason, with ACCDR's

Edit: (sorry, I probably made the same mistake I complain about in newbies - providing too much distracting and unnecessary background/context. The only question is really, why doesn't opencurrentdatabase work on accdr's, and what other option is there once one has fired up an Access.Application)
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:09
Joined
Oct 29, 2018
Messages
17,628
Hi Isaac. Since the runtime environment, which the accdr is probably in, doesn't allow design changes, I am guessing creating objects is considered to be in that category.
 

Isaac

Lifelong Learner
Local time
Today, 00:09
Joined
Mar 14, 2017
Messages
6,072
Ok, I think I got something working.

vbscript:
Code:
dim accessapp
set accessapp = createobject("access.application")
accessapp.opencurrentdatabase("path to intermediary accdb")

vba code in startup form of intermediary accdb:
Code:
Private Sub Form_Load()
CreateObject("Shell.Application").Open ("path to the accdr that I really want to open")
Application.Quit acQuitSaveNone
End Sub

This seems to work, all during such time as another database is already working and causing its own Access application instance to be frozen/un-useable.

Thanks all for input and letting me think out loud too! :)

I know a Scheduler type app is best left to its own devices on a lone machine, but I don't have that luxury right now.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:09
Joined
Oct 29, 2018
Messages
17,628
Ok, I think I got something working.

vbscript:
Code:
dim accessapp
set accessapp = createobject("access.application")
accessapp.opencurrentdatabase("path to intermediary accdb")

vba code in startup form of intermediary accdb:
Code:
Private Sub Form_Load()
CreateObject("Shell.Application").Open ("path to the accdr that I really want to open")
Application.Quit acQuitSaveNone
End Sub

This seems to work, all during such time as another database is already working and causing its own Access application instance to be frozen/un-useable.

Thanks all for input and letting me think out loud too! :)

I know a Scheduler type app is best left to its own devices on a lone machine, but I don't have that luxury right now.
Congratulations! Lemons and lemonade. :)
 

Users who are viewing this thread

Top Bottom