connecting access excel vba
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Connecting to Access from Excel VBA

Connecting to Access from Excel VBA

· Urgent Priority · Version 2003

replyReply Mon 12 Sep 2011, 12:32Delegate Sakeb said...

Sakeb has attended:
Excel VBA Intro Intermediate course

Connecting to Access from Excel VBA

Morning All

I am currently trying to develop a piece of code which will connect to an MS Access database and then kick off a Query on the table

I am using the following code:


Code:
Public strDB As String
Public A As Object
Public Function runaccessmacro()
Application.ScreenUpdating = False
Set A = CreateObject("Access.Application")
strDB = "S:\MI_Portal\TMNT\TMNT (TESTING).mdb"
A.OpenCurrentDatabase strDB
A.Visible = False
A.DoCmd.RunMacro "mcrUpdateNumberStatus"
A.Quit
Set A = Nothing
Application.ScreenUpdating = True
End Function

Sub run_access_macro()
Call runaccessmacro
End Sub

But this does not work and am presented with error message '7866', which suggests the table can not be found or is locked by another user

I have also tried to following code, but get the same error message:


Code:
Global oApp As Object

Sub OpenAccess()

Dim LPath As String
Dim LCategoryID As Long

'Path to Access database
LPath = "\\RLBYCCMPFS06\swap\MI_Portal\TMNT\TMNT (TESTING).mdb"

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

'Open Access database as defined by LPath variable
oApp.OpenCurrentDatabase LPath, False

'Open form called Categories filtering by CategoryID
oApp.Visible = False
oApp.DoCmd.RunMacro "mcrUpdateNumberStatus"
oApp.Quit

End Sub

Any suggestions??

For upcoming training course dates see: Pricing & availability

replyReply Fri 16 Sep 2011, 13:23Trainer Anthony said...

RE: Connecting to Access from Excel VBA

Hi Sakeb, thanks for your query. We'll get back to you asap on this one.

Anthony

replyReply Mon 3 Oct 2011, 10:44Delegate Sakeb said...

RE: Connecting to Access from Excel VBA

Hi Guys

It's been well over two weeks since I posted this question, yet still no answer - should I look elsewhere? I thought you guys were the experts

Rgds

Sakeb

 

Please browse our web site to find out more about
microsoft excel courses and other Microsoft training courses.

Excel tip:

Auto-insert the current time

In Microsoft Excel, to enter the current time into a cell, hold CTRL+SHIFT and press SEMICOLON.

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard