Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Data Connection: Access Query to Excel How to get rid of header ro

Hello.

I have created a data connection in Excel to an Access query. It does
exactly what I need however the header rows of the query are imported as well
and all I want are the data in the simplest way possible.

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Data Connection: Access Query to Excel How to get rid of header ro


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).
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Data Connection: Access Query to Excel How to get rid of header ro

Right-click anywhere in the datarange of the query. Select "Data Range
Properties..." from the menu. Uncheck the "Include field names" box.
Refresh the query. That should do it.

HTH,

Eric


"Der Musensohn" wrote:

Hello.

I have created a data connection in Excel to an Access query. It does
exactly what I need however the header rows of the query are imported as well
and all I want are the data in the simplest way possible.

Thanks in advance.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Data Connection: Access Query to Excel How to get rid of heade

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).

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
Excel data connection to Access not retrieving data from single fi dandc0711 Excel Programming 0 January 12th 10 03:52 PM
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
Data Connection from Excel to Access Deniz Yalman Excel Programming 0 March 3rd 08 09:10 AM
Excel data connection to Access Sharon Excel Discussion (Misc queries) 1 February 14th 08 08:33 PM


All times are GMT +1. The time now is 11:56 PM.

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"