lcpx
10-29-2005, 05:54 AM
Hi all,
I am new to this forum and a novice at VBA programming, only have couple of years experience of MS SQL.
I have 2 problems in VBA for Excel.
1. How to establish an ODBC connection in VBA for MS SQL Server, can anybody give me an example based on Northwind DB. Many thanks.
2. I also want to ask about Pass parameters into a SQL query in Excel.
In my work sheet, at the the first row, I would like my users can type a DateTime in the field A1 or whatever, and also select a value from a drop list next to it. for example, user can type date like: 2005-10-28 and select a product_code. Then press a button next to the field. At the end, the worksheet will display the result from SQL server DB.
Let's say: Select t.* from northwind.orders t where t.OrderDate = '2005-10-28' and t.shipcity like 'xxxxx'
I don't know how to pass the value typed by a user to a SQL query in VBA. Can anybody help me out, or is there any documents or demo I can have a look.
Thanks very much for your help.
I am new to this forum and a novice at VBA programming, only have couple of years experience of MS SQL.
I have 2 problems in VBA for Excel.
1. How to establish an ODBC connection in VBA for MS SQL Server, can anybody give me an example based on Northwind DB. Many thanks.
2. I also want to ask about Pass parameters into a SQL query in Excel.
In my work sheet, at the the first row, I would like my users can type a DateTime in the field A1 or whatever, and also select a value from a drop list next to it. for example, user can type date like: 2005-10-28 and select a product_code. Then press a button next to the field. At the end, the worksheet will display the result from SQL server DB.
Let's say: Select t.* from northwind.orders t where t.OrderDate = '2005-10-28' and t.shipcity like 'xxxxx'
I don't know how to pass the value typed by a user to a SQL query in VBA. Can anybody help me out, or is there any documents or demo I can have a look.
Thanks very much for your help.