Results 1 to 3 of 3
  1. #1
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281

    Access Opens Then Immediately Closes When Opened From Excel VBA

    Greetings...

    Not sure what I'm missing or not seeing but the below code works perfectly

    Code:
    Sub OpenAccess1 ()
    
    Dim AppAccess As Object
    Set AppAccess = CreateObject ("Access.Application")
    Call AppAccess.OpenCurrentDatabase ("N:\Sales\Internal\Confidential\ProdDept\Reports\Weekly\Sales.accdb")
    
    End Sub



    While the code below opens the Db but then as soon as the code hits End Sub - The Db immediately closes - very frustrating

    Code:
    Sub OpenAccess2 ()
    
    Dim AppAccess As Object
    Set AppAccess = CreateObject ("Access.Application")
    Call AppAccess.OpenCurrentDatabase ("N:\Production\Internal\ProdDept\Reports\MTD\Prod.accdb")
    
    End Sub
    I've tried using AppAccess.Visible = True
    I've used both early & late binding methods

    Same results

    Help?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,894
    If you want to keep the db open and give control to user:

    Sub OpenAccess2()
    Dim AppAccess As Access.Application
    Set AppAccess = CreateObject("Access.Application")
    AppAccess.Application.Visible = True
    AppAccess.UserControl = True
    AppAccess.OpenCurrentDatabase (CN:\Production\Internal\ProdDept\Reports\MTD\Prod .accdb")
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281
    June!!

    Thank You So, Soooo Much!!

    That did the trick!!

    Can't say I understand why the top few lines of code works to open and grant user control

    And the bottom code needs a little more hand holding - but it works, who am I to question

    Thanks again, June

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

Similar Threads

  1. Access Opens Excel, Edit, SaveAs, then Close
    By jadown in forum Programming
    Replies: 6
    Last Post: 03-09-2015, 09:50 AM
  2. Replies: 10
    Last Post: 07-25-2013, 07:36 AM
  3. XML file opens in excel 2010/2013 correctly but not in Access
    By flebber in forum Import/Export Data
    Replies: 1
    Last Post: 05-21-2013, 09:23 PM
  4. Replies: 1
    Last Post: 01-22-2013, 09:51 AM
  5. Close and Save Excel file already opened in Access
    By DB2010MN26 in forum Programming
    Replies: 7
    Last Post: 01-19-2012, 06:50 PM

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