Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Quick Queries #91    Comments List
Pending Approval    Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 

Anonymous 
 
Sandra Truax  @Reply  
         
2 months ago

Sandra Truax  @Reply  
         
2 months ago
My porch light came on while I was typing this and I used your ShiftIsPressed code to determine whether or not to close the current database when an item is selected. That way I can either switch or have them both open and don't have to use the link on my computer.
Richard Rost  @Reply  
          
2 months ago
You should be able to do this with the Shell command by launching MSACCESS.EXE directly and passing the database file as a command-line argument. In other words, don't just shell (or FollowHyperlink) the ACCDB file itself. Shell Access, then give it the database path.

Something like:

Shell """C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE"" ""C:\MyFolder\MyDatabase.accdb""", vbNormalFocus

That should open the selected database in a separate Access process. The key is making sure both paths are wrapped in quotes, especially if there are spaces in the folder or file names.
Sandra Truax  @Reply  
         
2 months ago
Richard That was the first thing I tried, but it opens it in the existing process if another database is open. I even tried opening the link file that has the "C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE" in it, and it opened in an existing process.
Darrin Harris  @Reply  
     
2 months ago
Hello Sandra

Richards code works for me opens in a new process.
If you break Richards code down it would look like this:

    Dim AccessPath As String
    Dim FilePath As String
    Dim FileName As String

    AccessPath = """C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE"" """
    FilePath = "C:\MyFolder\"
    FileName = "MyDatabase.accdb"""

    Shell AccessPath & FilePath & FileName, vbNormalFocus
Sandra Truax  @Reply  
         
2 months ago
Darrin I agree the code opens the database, but in Task Manager it is not in it's own process, at least not for me. I've got it working by putting the following in a .bat file, then I can open it in Access and it will be in another process in the Task Manager.

start "" "C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE" %1

DetailsDim DBPath As String
    Dim AccessPath As String
    Dim Cmd As String
    
    DBPath = Me.DatabaseListbox.Column(1) & _
             Me.DatabaseListbox.Column(0) & ".accdb"

    Cmd = """D:\-\Bat Files\OpenDB.bat"" " & _
          """" & DBPath & """"

    Debug.Print Cmd

    Shell Cmd, vbHide
    
    If ShiftIsPressed Then Exit Sub
    Application.Quit
Darrin Harris  @Reply  
     
2 months ago
Sandra have you tried to let shell find Access

    Dim objShell As Object
    Dim dbPath As String
    
    dbPath = "C:\MyFolder\MyDatabase.accdb"
    
    Set objShell = CreateObject("WScript.Shell")
    objShell.Run dbPath
    Set objShell = Nothing
Sandra Truax  @Reply  
         
2 months ago
Darrin Just tried that and it still does not open it in the Task Manager in it's own process. It added it under the existing one if another database is open. Thanks though.
Darrin Harris  @Reply  
     
2 months ago
Sorry Sandra got one more

    Dim accApp As Object

    Set accApp = CreateObject("Access.Application")

    accApp.OpenCurrentDatabase "C:\MyFolder\MyDatabase.accdb"
    accApp.Visible = True
    accApp.UserControl = True

    Set accApp = Nothing

I know the bat file is working, and if it works then its all good.
I hope this works, if not that's all I got lol

Take care
Sandra Truax  @Reply  
         
2 months ago
Darrin You are a genius!  This one works!  After I modified it to use the list box it is opening them in their own process!  No more .bat file for me! Thank you so much. After two days of trying, I had given up.

DetailsPrivate Sub DatabaseListbox_Click()
    
    Dim DBPath As String
    Dim accApp As Object
    
    DBPath = Me.DatabaseListbox.Column(1) & _
             Me.DatabaseListbox.Column(0) & ".accdb"

    Set accApp = CreateObject("Access.Application")

    accApp.OpenCurrentDatabase DBPath
    accApp.Visible = True
    accApp.UserControl = True

    Set accApp = Nothing

End Sub
Richard Rost  @Reply  
          
2 months ago
Glad I could help. :)

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Quick Queries #91.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 7/14/2026 11:50:31 AM. PLT: 1s