Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Location: Portland, Oregon
Posts: 26
Default Cut the umbilical cord? Access connection to Excel

I have a sheet where I have data from an Access table imported (Data --
Import External Data -- Import Data...). No problem there. What I've
discovered is that a connection, it seems, stays open between Excel and Access
so that, in effect, that particular Access data source is "open" and remains
so until Excel is closed or the Excel file is Saved As something else -- but
if Refresh Data is performed then that link is established again and the
problem is back.

Now this is bad because the Access mdb cannot be opened for
changes/edits/modifications because it acts like it is opened by another user
(and technically it is). So I'm thinking about having VBA severe the
connection after the data has been downloaded because that's what seems to
happen when the file is saved elsewhere or if it's opened without a Refresh.
Can this be done and if so, how?
--
Toby Erkson
Oregon, USA


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Cut the umbilical cord? Access connection to Excel

Hi Toby,

This isn't the way it's supposed to work (at least I have never run into
this before). Do you have your MDB set up as a single-user database (set to
open exclusively)? What exact steps did you take to set up the database
query?

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Toby Erkson wrote:
I have a sheet where I have data from an Access table imported (Data
-- Import External Data -- Import Data...). No problem there.
What I've discovered is that a connection, it seems, stays open
between Excel and Access so that, in effect, that particular Access
data source is "open" and remains so until Excel is closed or the
Excel file is Saved As something else -- but if Refresh Data is
performed then that link is established again and the problem is back.

Now this is bad because the Access mdb cannot be opened for
changes/edits/modifications because it acts like it is opened by
another user (and technically it is). So I'm thinking about having
VBA severe the connection after the data has been downloaded because
that's what seems to happen when the file is saved elsewhere or if
it's opened without a Refresh. Can this be done and if so, how?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Cut the umbilical cord? Access connection to Excel

Use ADO to connect to your database using the open method to establish the
connection

Something like.......

Sub ADOMethod()
' make a reference to Microsoft ActiveX Data Obects Library

Dim dCon As New Connection
Dim dRecs As New Recordset
Dim dSQL As String

dCon.Open "Provider=microsoft.jet.oledb.4.0;" + _
"Data Source=your path and mdb file.mdb"

dSQL = "your database query string"

dRecs.Open Sql, dCon

While Not dRecs.EOF

'Load your data records into the worksheet

Wend

dRecs.Close: dCon.Close
End Sub

Cheers
Nigel

"Toby Erkson" wrote in message
...
I have a sheet where I have data from an Access table imported (Data --
Import External Data -- Import Data...). No problem there. What I've
discovered is that a connection, it seems, stays open between Excel and

Access
so that, in effect, that particular Access data source is "open" and

remains
so until Excel is closed or the Excel file is Saved As something else --

but
if Refresh Data is performed then that link is established again and the
problem is back.

Now this is bad because the Access mdb cannot be opened for
changes/edits/modifications because it acts like it is opened by another

user
(and technically it is). So I'm thinking about having VBA severe the
connection after the data has been downloaded because that's what seems to
happen when the file is saved elsewhere or if it's opened without a

Refresh.
Can this be done and if so, how?
--
Toby Erkson
Oregon, USA




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Location: Portland, Oregon
Posts: 26
Default Cut the umbilical cord? Access connection to Excel

Nigel, thanks but too much work right now so Jake...

Good questions. It's been YEARS since I've used Access with any proficiency
so bear with me. I'm currently using MS Access 2002, SP-2, on XP.
Yes, single user...how would I change this?
The only modification I made to the query was change the network drive path
into a UNC path.

Toby

"Jake Marx" wrote in message
...
Hi Toby,

This isn't the way it's supposed to work (at least I have never run into
this before). Do you have your MDB set up as a single-user database (set to
open exclusively)? What exact steps did you take to set up the database
query?

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Cut the umbilical cord? Access connection to Excel

Hi Toby,

Toby Erkson wrote:
Good questions. It's been YEARS since I've used Access with any
proficiency so bear with me. I'm currently using MS Access 2002,
SP-2, on XP.
Yes, single user...how would I change this?


Tools | Options, Advanced tab...look under Default open mode.

The only modification I made to the query was change the network
drive path into a UNC path.


So you created the query using the Query Wizard, right? What did you select
as the data source? The ODBC driver for Access, or do you have a DSN set up
already?

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Location: Portland, Oregon
Posts: 26
Default Cut the umbilical cord? Access connection to Excel

Default open mode was shared. Well, still is shared.
ODBC driver for Access.

Now, I had the db open. When I opened the workbook a very odd window popped
up:
Please Enter MS JET OLE DB Initialization Information
and it showed the data source, user name, etc., and the last item was Open
Mode: with a drop-down box. In it was selected DB_MODE_READWRITE.

Ah-soo.

So I selected DB_MODE_SHARE_DENY_NONE. Clicked OK and the data downloaded and
everything worked like it was supposed to. Here is the new output of the
connection from the "Edit OLE DB Query" from the Edit Query... menu item:

Provider=Microsoft.Jet.OLEDB.4.0;Password="";User ID=Admin;Data
Source=\\pdxberkompas02\Reporting$\public_reportin g\Siebel_Export.mdb;Mode=Sha
re Deny None;Extended Properties="";Jet OLEDB:System database="";Jet
OLEDB:Registry Path="";Jet OLEDB:Database Password="";Jet OLEDB:Engine
Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk
Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database
Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt
Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact
Without Replica Repair=False;Jet OLEDB:SFP=False

The key is "Mode=Share Deny None" in the second sentance above. Previously it
was ReadWrite (or close to that) and that, I surmise, was my problem. Now
everything is fine.

Thanks Jake for helping me along :-) Now I know how to configure my other
queries for this process.

Toby

"Jake Marx" wrote in message
...
Hi Toby,

Toby Erkson wrote:
Good questions. It's been YEARS since I've used Access with any
proficiency so bear with me. I'm currently using MS Access 2002,
SP-2, on XP.
Yes, single user...how would I change this?


Tools | Options, Advanced tab...look under Default open mode.

The only modification I made to the query was change the network
drive path into a UNC path.


So you created the query using the Query Wizard, right? What did you select
as the data source? The ODBC driver for Access, or do you have a DSN set up
already?

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]



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
Excel 2010 (64 bit) External Data connection with Access Bill Carlson Excel Discussion (Misc queries) 0 June 2nd 11 12:10 AM
Connection of Excel 07 pivot table to Access Query makes DB read o Chuck W[_2_] Excel Discussion (Misc queries) 0 October 9th 09 03:45 PM
reconnecting a workbook connection from Access-Excel Steven Cheng Excel Discussion (Misc queries) 0 December 11th 08 04:46 PM
Excel data connection to Access Sharon Excel Discussion (Misc queries) 1 February 14th 08 08:33 PM
Can Excel and access update each other like a two way connection CmK Excel Discussion (Misc queries) 0 February 23rd 07 01:01 PM


All times are GMT +1. The time now is 07:36 AM.

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

About Us

"It's about Microsoft Excel"