Link to home
Start Free TrialLog in
Avatar of JP_TechGroup
JP_TechGroupFlag for United States of America

asked on

Open Access table from Excel vba - Office 2007

I have s small macro intended to open a table in Access for viewing. The code executes, but the database only remains open long enough to immediately close! How to address so the access table remains visible?
Public Sub open_dbase()

    Dim LPath As String
    Dim LCategoryID As Long

    'Path to Access database
    LPath = Sheet2.Cells(5, 2)

    'Open Access and make visible
    Set oApp = CreateObject("Access.Application")
   

    'Open Access database as defined by LPath variable
    oApp.OpenCurrentDatabase LPath
    oApp.DoCmd.OpenTable "tblRawData", acViewNormal
    oApp.Visible = True
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
what do you want to achieve by opening the table?

if u want the data from it then use a recordset

or are you actually wanting msaccess to open and remain open with that table open
Have you double checked that access is still left opened? it might be behind your excel window, check the taskbar
Avatar of JP_TechGroup

ASKER

That did it. Thanks!
so mx, whats the secret? I gave it a little test from excel and for me db with table remains open, didnt need the usercontrol
Secret ?
Not sure.  It was the only thing I could think of.  I have in my database loader, which keeps the loaded mdb open, then closes the loader.

mx