Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Can't re-open Access database from Excel VBA

I have an Excel application that through VBA opens an Access database, works
on it, and then closes it. This functions well.

But when I re-open it, I do not get a correct connection to the database.
I have extracted a small portion of my VBA and included it below. What is
wrong ?

I use CurrentDB to check whether all is OK.

I get the following error message :
Run-tiome error '-2147417848 (80010108)':
Automation Error
The object invoked has disconnected from its clients.

In my application from which the VBA below is extracted (and simplified) I
get the following error message :
Run-time error '462':
The remote server machine does not exist or is unavailable

'========================== VBA start ==========================
Option Explicit

Const wInDB As String = "C:\WILMAR\Wilmar database.mdb"
Public InAccess As Object

Sub HVL_Write_Queries()

' You need a reference to Microsoft Access 9.0 Object Library
' Use menu "Tools / References".

Dim OK As Boolean
Dim X As Object

OK = Open_Access_InDB
Set X = CurrentDB ' This is OK.
OK = Close_Access_InDB

OK = Open_Access_InDB
Set X = CurrentDB ' ERROR !
OK = Close_Access_InDB

End Sub

Function Open_Access_InDB() As Boolean

Dim Exclusive_Mode As Boolean, OK As Boolean

Exclusive_Mode = False
OK = True

If InAccess Is Nothing Then
Set InAccess = New Access.Application
InAccess.OpenCurrentDatabase wInDB, Exclusive_Mode
End If

InAccess.Visible = False

Open_Access_InDB = OK

End Function

Function Close_Access_InDB() As Boolean

Close_Access_InDB = True

InAccess.Quit acQuitPrompt ' This makes the Access window visible. No
database open.
Set InAccess = Nothing

End Function
'========================== VBA end ==========================


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Access Database with VBA Bubba Excel Discussion (Misc queries) 1 July 19th 05 10:53 PM
Open Access Database with VBA Keith Excel Discussion (Misc queries) 1 June 1st 05 07:18 PM
Open Access Database under and Excel window using a Macro BMSpell Excel Worksheet Functions 1 January 8th 05 05:32 PM
checking if an access database is open from excel macro Keyur Excel Programming 0 April 16th 04 04:03 PM
Open Ms Access database with excel macro Sani Excel Programming 2 November 19th 03 06:06 AM


All times are GMT +1. The time now is 01:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"