ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   External Data (https://www.excelbanter.com/excel-programming/274158-external-data.html)

James[_11_]

External Data
 
I am trying to pass a SQL query with variables in the
WHERE clause through the external data function and can't
seem to get it to work. For instance, I want to pull back
a specific property or a group and the cash flows for the
last year depending on variables my user inputs using a
drop down. Any suggestions would be very appreciated.

Thank you.

Patrick Molloy[_4_]

External Data
 
It woulf be useful to see your code.
however, your WHERE should look something akin to


DIM sSQL as String

sSQL ="Select [Field1],[Field2][,[fieldn]] FROM mytable WHERE [ThisField] =
'" & textbox1.text & "'"
sSQL = sSQL & " AND MyValue = " & txtbox2.text & ";"

note that for char type fields, wrap your text in single quotes. Numeric
fields don't need the quote

--
Patrick Molloy
Microsoft Excel MVP
----------------------------------
"James" wrote in message
...
I am trying to pass a SQL query with variables in the
WHERE clause through the external data function and can't
seem to get it to work. For instance, I want to pull back
a specific property or a group and the cash flows for the
last year depending on variables my user inputs using a
drop down. Any suggestions would be very appreciated.

Thank you.





All times are GMT +1. The time now is 05:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com