I have two Microsoft Access database tables. They are named Historical_Stock_Prices
and Balance_Sheets
. I need to combine data from each of these tables to create a table called Daily
. I need to take the fields Ticker
, [Date]
, and [Close]
from Historical_Stock_Prices
and I need to take the field Common_Stocks
from Balance_Sheets
.
I will not be taking every row from the Historical_Stock_Prices
and Balance_Sheets
though. I will only be taking the rows that are on or before a date selected in a DateTimePicker
named dtpDateSelection
.
Now the main problem that I have is that Historical_Stock_Prices
contains a row for each day. While Balance_Sheets
contains a row for each quarter. So for each day in a quarter the figure Common_Stocks
figure that comes from Balance_Sheet
will be the same.
How do I do this?
Here is the code that I have so far:
Dim Date1 As Date = dtpDateSelection.Value
Dim cmd As OleDbCommand = New OleDbCommand("CREATE PROC Daily AS SELECT Ticker, [Date], [Close] From Historical_Stock_Prices WHERE [Date] = " & Date1 & "", con)
cmd.ExecuteNonQuery()
This obviously does not incorporate the table Balance_Sheet
at all. Also, currently my where statement is throwing an error.
Additional Information: Table Schema