Results 1 to 7 of 7
  1. #1
    swas is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Apr 2017
    Posts
    32

    Open db2 from db1 then quit db1 with db2 still running

    Hello,

    I think the title pretty much explains what I want to do.



    Use shell(db2) kills db2 when db1 quits.

    Use Followhyperlink waits for db2 hence db1 won't quit.

    Use automation (Acces.Automation) waits too.

    My thoughts may be use a bat file, and shell to it which then opens db2 without waiting. Just seems a little tacky.

    I just need to open db2, and essentially by the time db2 has opened db1 should have quit. db2 subsequently opens db1 exclusively, hence the need for db1 to close.


    Thoughts?

    Thanks

    mrswas

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    This keeps coming up so I did a quick example a few months back

    It can be done much more simply than that.
    See attached example
    Modify the path of the external database in the code before clicking the button on the form.

    However I always wonder why the external database tables can't just be linked & whatever you want to do then done from database 1

    HTH
    Attached Files Attached Files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    swas is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Apr 2017
    Posts
    32
    Thanks very much for that, works just how I need.

    Not real sure what part of some similar trial code I used that makes it different:

    Code:
    Dim oAccess               As Access.Application
     
    Set oAccess = CreateObject("Access.Application")    
        With oAccess
            .OpenCurrentDatabase strTmp    'strTmp = the specified db
            .visible = True             
            .UserControl = True
        End With
    
    
    Application.Quit
    The only difference I can see was using CreateObject, or .visible (Not needed) or maybe .UserControl. Either way I'm happy...

    To try and save you wondering, db1 is the front end of our database. db2 is only for updating - it doesn't touch any data tables in db1. db2 grabs db1 exclusively only to know it has fully closed, then grab a couple of properties (Like where the back end is). It then unzips a new db1 update file, does a few checks, renames old db1 as a backup to allow restore, replaces db1 with the update, sets the back end etc..., then restarts db1. db2 function in life has now ended and gets deleted by db1.

    I can't do this from db1.


    Thanks again.

    swas

  4. #4
    swas is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Apr 2017
    Posts
    32
    The plot thickens...

    I hadn't tried your code in my main project - only with a small separate db to test where it worked, but failed when I set up correctly in my db.

    The problem was my db2 startup stuff had a msgbox displaying, and this was the cause of all my issues...

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Ok I'm lost...
    Have you got a solution or not?
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  6. #6
    swas is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    Apr 2017
    Posts
    32
    My apologies...

    Yes I have it working. My original code would have worked - the issue was the db2 had a msgbox when opening, and that stopped the process.

    I appreciate the help.

    swas

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    You're welcome
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 10-29-2015, 07:03 AM
  2. MS ACCESS-Running Module to open Excel
    By BLUDEV in forum Macros
    Replies: 4
    Last Post: 02-10-2015, 04:52 PM
  3. Replies: 11
    Last Post: 06-16-2014, 08:52 AM
  4. Query running on DoCmd.Quit?
    By ts_hunter in forum Access
    Replies: 2
    Last Post: 02-06-2014, 10:16 AM
  5. Replies: 1
    Last Post: 02-13-2012, 10:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums