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: 8
Default ADO retrieval from close workbook-data type issue

I use the following procedures to retrieve data from a closed workbook and it works really well with one exception. If there is a column of data that is of mixed type, only the numeric data is retrieved, the alpha-numerics are omitted. Is there a way to modify the SELECT statement so that I get all the data, regardless of data type? I know database stuff is a lot more particular than Excel as far as data types, but, I really would like to not have to restrict some columns to a particular type, and I would like to access it through the below code, or something similar. In the sample below the data goes to a listbox; I have the same problem when it goes directly to the worksheet as it just doesn't get to be part of the recordset.
Thanks
Ken


Sub ADO_item_stones()
Dim src As String
src = "SELECT * FROM [Item_Milestones]"
Call ADO_items(src)
End Sub

Sub ADO_(fltr)

Dim Cnct As String, src As String
Dim Connection As ADODB.Connection
Dim recordset As ADODB.recordset
Dim dbfullname As String
Dim sh As String

'Construct Database information string and open the connection

Set Connection = New ADODB.Connection

dbfullname = Application.Substitute(ThisWorkbook.Path, "\Subcontracts", "\Estimates")
dbfullname = dbfullname & "\" & "Consolidated " & Sheet2.Range("job")..Value & ".xlsm"

Cnct = "Provider=Microsoft.ACE.OLEDB.12.0;"
Cnct = Cnct & "Data Source=" & dbfullname & ";"
Cnct = Cnct & "Extended Properties=Excel 12.0"

On Error GoTo 300

Connection.Open ConnectionString:=Cnct

'Create RecordSet

Set recordset = New ADODB.recordset

recordset.Open Source:=fltr, ActiveConnection:=Connection

'Write the data to the listbox

Do Until recordset.EOF

With Stones.ListBox1
.AddItem recordset!Milestone
.list(.ListCount - 1, 1) = recordset!Name
.list(.ListCount - 1, 2) = recordset!Start
End With

recordset.MoveNext

Loop

Stones.Show

Set recordset = Nothing
Connection.Close
Set Connection = Nothing

Exit Sub

300

MsgBox "Could not connect to " & dbfullname

End Sub
 
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
IF AND MATCH data type issue EZ[_2_] Excel Worksheet Functions 2 June 18th 09 05:35 PM
Possible Data Type Issue shelfish Excel Programming 3 May 31st 08 11:18 PM
Auto execute upon workbook retrieval TOMD Excel Discussion (Misc queries) 0 February 7th 07 08:12 PM
Column retrieval as an input to an existing workbook NaomiKay Excel Discussion (Misc queries) 8 March 6th 06 11:28 AM
Open / Close Workbook Memory issue David Edison Excel Programming 0 November 17th 04 10:09 AM


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