I have a SQLite database that contains financial data. The code is working and exporting data correctly. However whenever any text fields are located, e.g. Earningsdate, Ticker and CompanyName it will not output the data correctly. I have set every Database item field as a REAL datatype. If I change the Ticker, CompanyName and Earningsdate fields to the Blob or Text datatype then nothing is output at all.
Here is the output in Excel:
As you can see, the CompanyName, Ticker and EarningsDate aren't reported correctly.
Below is what those respective fields look like in the Database:
EarningsDate 16 Jul 2020 - 20 Jul 2020 [type of data is Text / Numeric]
CompanyName Microsoft [type of data is Text / Numeric]
Ticker MSFT [type of data is Text / Numeric]
I'm not sure why these non numeric types aren't outputting properly given that the VBA code says to get all records.
VBA Code:
Sub GetData()
Dim conn As ADODB.Connection
Dim TestData As ADODB.Recordset
Dim icols As Integer
Dim code As Range
Set code = Worksheets("Sheet1").Range("D1")
Dim r As Variant
r = code.Value
Set conn = New ADODB.Connection
Set TestData = New ADODB.Recordset
conn.Open "DRIVER=SQLITE3 ODBC DRIVER;DATABASE=C:\Users\jaz\financials.db;"
strSQL = "SELECT * FROM financials WHERE Ticker= '" & r & "'"
TestData.Open strSQL, conn
For icols = 0 To TestData.Fields.Count - 1
Worksheets("Sheet2").Cells(1, icols + 1).Value = TestData.Fields(icols).Name
Next icols
Worksheets("Sheet2").Range("A2").CopyFromRecordset TestData
TestData.Close
Set TestData = Nothing
Set conn = Nothing
End Sub
Here is the output in Excel:
As you can see, the CompanyName, Ticker and EarningsDate aren't reported correctly.
Below is what those respective fields look like in the Database:
EarningsDate 16 Jul 2020 - 20 Jul 2020 [type of data is Text / Numeric]
CompanyName Microsoft [type of data is Text / Numeric]
Ticker MSFT [type of data is Text / Numeric]
I'm not sure why these non numeric types aren't outputting properly given that the VBA code says to get all records.