Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
IF AND MATCH data type issue | Excel Worksheet Functions | |||
Possible Data Type Issue | Excel Programming | |||
Auto execute upon workbook retrieval | Excel Discussion (Misc queries) | |||
Column retrieval as an input to an existing workbook | Excel Discussion (Misc queries) | |||
Open / Close Workbook Memory issue | Excel Programming |