Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you Arjen and Eric. I had time enough to go ahead and change the
properties as Eric suggested but thank you both. "arjen van der wal" wrote: It depends on how you setup the data connection. If you're doing it in VBA using ADO and a reference to the query, the default is to not import the field headings. If you're doing it without VBA, using Get External Data on the Data ribbon in Excel 2007 you'll get the headings. Here's a short example using Microsoft's Northwinds sample database: Public Sub AccessQuery() Dim rsData As ADODB.Recordset Dim sConnect As String sConnect = "Provider=Microsoft.Ace.OLEDB.12.0;" & _ "Data Source=C:\VB 2008\Northwind 2007.accdb" 'create the recordset object and run the query Set rsData = New ADODB.Recordset rsData.Open "[Inventory on Hold]", sConnect, adOpenForwardOnly, adLockReadOnly, adCmdTable 'put the contents of the recordset into the worksheet Sheet6.Range("A1").CopyFromRecordset rsData Sheet6.UsedRange.EntireColumn.AutoFit 'close the record set object rsData.Close 'destroy the record set object Set rsData = Nothing End Sub I should note that you will also have to add a reference to the ADO object library when you create the project (In VBA editor Tools References & look for Microsoft Active X Data Objects Library, whichever is the latest edition). |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2010 (64 bit) External Data connection with Access | Excel Discussion (Misc queries) | |||
Excel data connection to Access not retrieving data from single fi | Excel Programming | |||
Connection of Excel 07 pivot table to Access Query makes DB read o | Excel Discussion (Misc queries) | |||
Data Connection from Excel to Access | Excel Programming | |||
Excel data connection to Access | Excel Discussion (Misc queries) |