[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Open Access table from Excel vba - Office 2007

Posted on 2010-09-13
7
Medium Priority
?
1,049 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 1

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

650 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