I am designing some dynamic graphs and what I would like to do is after selecting the portfolio of interest from a ComboBox it would send the name/value of the portfolio to a SQL query to collect the data. At the moment after selecting the variable the Combo Box unloads the value to cell B1.
In the graph macro I define the variable, Selected_Portfolio, as a string and initiate it per
Selected_Portfolio = Range("B1").Value
The SQL statement is then written as
sqlStr = "select * from ( "
sqlStr = sqlStr & "select Top 30 PFDate, RiskValue from dbo.Portfolios "
sqlStr = sqlStr & "where PortName = ' & Selected_Portfolio & '"
sqlStr = sqlStr & "order by PFDate desc) sub "
sqlStr = sqlStr & "order by PFDate"
The issue I have is that I do not believe I am passing Selected_Portfolio correctly. I know this because if the hard code PortName with a specific portfolio it works.
Thanks in advance