Solved

Open Access table from Excel vba - Office 2007

Posted on 2010-09-13
7
830 Views
Last Modified: 2012-05-10
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

0
Comment
Question by:JP_TechGroup
  • 3
  • 3
7 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 33667394
Try adding the line of code shown below:


    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
    oApp.UserControl = True   ' ************ ADD THIS LINE

mx
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33667396
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
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33667418
Have you double checked that access is still left opened? it might be behind your excel window, check the taskbar
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Closing Comment

by:JP_TechGroup
ID: 33667449
That did it. Thanks!
0
 
LVL 75
ID: 33667461
You are welcome ...

mx
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33667860
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
0
 
LVL 75
ID: 33668318
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
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now