LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Extracting Data from Access dB to Excel, using VBA

Ignore this post.
I somehow thought you were talking about spaces in the table name.

RBS


"RB Smissaert" wrote in message
...
Just a quick guess, but try this:

sSelectString = "SELECT * FROM [" & sTableName & "];"
instead of:
sSelectString = "SELECT * FROM " & sTableName & ";"


RBS



"Clarkyboy420" wrote in message
...
Hi All,

Firstly, I'm an amateur on a steep learning curve, so please excuse me if
some of my terminology/understanding is incomplete.

I have found a VBA procedure which will extract entire tables from a db
to a
grid array in an excel spreadsheet. The procedure relies on two cell
values,
one identifies the database path, the other identifies the required
table.
When the procedure is run, it evaluates the two values and returns the
specified table in its entirety.

The problem I am having is that it works perfectly for tables that have
no
'dead-space', ie blank fields, however, if there is even one blank
field/cell
in the db table, then the VBA procedure fails to return any data
whatsoever.

I have been led to believe that the issue is I need a 'null handling'
section in my procedure, but have to admit I have no idea how to begin
coding this at my present knowledge level.

I would greatly appreciate any help with this one. Massive thanks in
advance.

Chris Clark

Please find below my current procedure;

Function GetInfoFromAccess( _
sDBFullName As String, _
sTableName As String) As Variant

Dim vResult As Variant
Dim oCN As ADODB.Connection, oRS As ADODB.Recordset

' open the database
Set oCN = New ADODB.Connection
Dim sCNString As String
sCNString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & _
sDBFullName & ";"
oCN.Open sCNString

Set oRS = New ADODB.Recordset
With oRS
' all records
Dim sSelectString As String
sSelectString = "SELECT * FROM " & sTableName & ";"
.Open sSelectString, oCN

vResult = oRS.GetRows ' gets all the rows from the data returned
End With

' close down recordset & connection
oRS.Close
Set oRS = Nothing

oCN.Close
Set oCN = Nothing

GetInfoFromAccess = vResult
End Function



 
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
Extracting Data from Access dB to Excel, using VBA EricG Excel Programming 0 November 17th 09 07:06 PM
Extracting data from Access in Excel Shahid Excel Programming 4 October 9th 07 04:44 PM
Extracting data from Access Daniel Bonallack Excel Programming 1 October 11th 06 07:15 AM
Extracting Excel data and uploading to access JBP Excel Programming 1 January 23rd 04 07:42 PM
Extracting Access data Tom Brooks Excel Programming 0 July 8th 03 02:41 PM


All times are GMT +1. The time now is 06:14 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"