M mr_hiboy Member Jul 16, 2013 #1 Hey, I was wonder if it is possible to have a macro retrieve data from a sql database using some parameters in a workbook, basic example. Cell A1 has customerID, if I enter 123 and run a macro can it select customer 123 from a database to show name is cell B1 Thanks Paul
Hey, I was wonder if it is possible to have a macro retrieve data from a sql database using some parameters in a workbook, basic example. Cell A1 has customerID, if I enter 123 and run a macro can it select customer 123 from a database to show name is cell B1 Thanks Paul
Luke M Excel Ninja Staff member Jul 16, 2013 #2 Certainly. When you setup the SQL query, you can define some of the criteria to be Parameters. See here: http://office.microsoft.com/en-us/excel-help/customize-a-parameter-query-HP010216113.aspx?pid=CH100648471033 Then, in your macro, you could just arrange for the correct data to be placed in the parameter cell before running the query.
Certainly. When you setup the SQL query, you can define some of the criteria to be Parameters. See here: http://office.microsoft.com/en-us/excel-help/customize-a-parameter-query-HP010216113.aspx?pid=CH100648471033 Then, in your macro, you could just arrange for the correct data to be placed in the parameter cell before running the query.
SirJB7 Excel Rōnin Jul 16, 2013 #3 Hi, mr_hiboy! Adding my two cents to the helpful link posted by Luke M, if you find any issue consider posting the macro with the SQL string build & connection so as to try to fix in the rude way, i.e., changing the query definition string. Regards!
Hi, mr_hiboy! Adding my two cents to the helpful link posted by Luke M, if you find any issue consider posting the macro with the SQL string build & connection so as to try to fix in the rude way, i.e., changing the query definition string. Regards!
M mr_hiboy Member Jul 17, 2013 #4 Thanks for getting back to me, I'll be looking at this at some point today.