Search : in
By :

Use sql query in excel macro

Last answer on Feb 2, 2009 12:13:54 pm GMT smd, on Feb 2, 2009 9:58:31 am GMT 
 Report this message to moderators

Hello,

i have created a sql query using "new database query" in excel. i need to use that query in a macro and use variables in the query.
the bold text needs to be substituted with variable which i get as user input.
for example fd00000001 needs to be fund_name and 2007-11-30 00:00:00.000 needs to cutoff and 0.5 needs to be unit_filter. these three variable will get data from another sheet based on list selection by the user.


.CommandText = Array("SELECT FPREDEAL.HOLDER, DNUCLEUS.REFERENCE , SUM(FPREDEAL.HOLDING) , FPREDEAL.FUND FROM FPREDEAL INNER JOIN DNUCLEUS ON FPREDEAL.HOLDER = DNUCLEUS.CODE WHERE (", "FPREDEAL.FUND = 'fd00000001') AND (FPREDEAL.DEALT = 'Y') AND (FPREDEAL.SETTLED = 'Y') AND (FPREDEAL.REVERSED <> 'Y' OR FPREDEAL.REVERSED IS NULL) AND (FPREDEAL.DEALING_DATE <= '", "2007-11-30 00:00:00.000') GROUP BY DNUCLEUS.REFERENCE, FPREDEAL.HOLDER, FPREDEAL.FUND having (sum(fpredeal.holding)>=0.5)")

Configuration: Windows XP
Firefox 3.0.5

Best answers for « use sql query in excel macro » in :
Excel tips : How to insert date in a cell ShowExcel tips : How to insert date in a cell Below are some tips on how to insert date and time in an excel cell for a specific purpose:- To insert current date, press CTRL ¯+ ;¯ in the chosen cell. To insert current time, press CTRL¯+...
Connect a database (MDB) to excel Show[VBA] Connecting a database (MDB) to excel Below is a tips of how to connect an Access database (MDB) in an application excel Add reference Microsoft DAO object librairy X.X In a general module (eg Module1) paste the code below...
[SQL] avoid duplicates when using SELECT Show[SQL] avoid duplicates when using SELECT Issue How to avoid duplicates in the results of a SQL query? Solution Simply use the DISTINCT clause and between the SELECT clause and the fields. Example: SELECT distinct...
Download EMS SQL Query for PostgreSQL ShowTo store and handle your information, the use of a database such as PostegreSQL simplifies your task. By means of different queries, you can easily extract information which you need at any time. EMS SQL Query for PostgreSQL is a program to...
Download Flyspeed SQL Query ShowDescription The application is designed ActiveDBSoft. Flyspeed SQL Query is a tool for developers and database users. Simple and easy to use, the application has been awarded from various places. The application enables users to build queries on...
Download Flyspeed SQL Query ShowFlyspeed SQL Query is an efficient database manager for developers. It does not require a deep knowledge on SQL syntaxes and allows you to create queries on different database servers. In order to handle your data, it lets you perform different...
SQL injection attacks ShowSQL Injection SQL injection attacks are attacks against websites that rely on relational databases. In this type of site, parameters are passed to the database in the form of an SQL query. As such, if the designer does not verify the parameters...

1

 hollow21, on Feb 2, 2009 12:13:54 pm GMT

Hi,
try this link to get the information you sare searching for.
http://www.bokebb.com/dev/english/2027/posts/2027134188.shtm­l
hope it helps you.

Reply to hollow21