PDA

View Full Version : SQL statements with VBA



kguerrero
06-15-2012, 10:38 AM
Hi,

In excel's connection properties, I have an SQL command that looks like this:

SELECT

himpl_wiplog_0.w, himpl_wiplog_0.u, himpl_wiplog_0.logfile,
himpl_wiplog_0.e, himpl_wiplog_0.d, himpl_wiplog_0.c,
himpl_wiplog_0.s, himpl_wiplog_0.sc, himpl_wiplog_0.pos_no,
himpl_wiplog_0.type

FROM
process.himpl_wiplog himpl_wiplog_0

WHERE
himpl_wiplog_0.logfile="J70"

ORDER BY
himpl_wiplog_0.ped_pos_no

I'd like to create VBA script to change the "J70" to another value. A point in the right direction will be very helpful.

I'd like to use VBA script since I'll also be using this value in other aspects (ie exporting sheets to CSV).

Thanks a ton,

Bob Phillips
06-15-2012, 11:46 AM
Where is this SQL code, do you mean you want dynamic SQL or to change an SQL script?

kguerrero
06-15-2012, 12:00 PM
Hi xld,

In excel - under the Data Tab - Connections. When the connection box opens up, I select a connection then select properties.

Connection properties window opens up. There is a tab for Definition. Under command text - the SQL command is entered here.

I am not going to give the user access to change columns and rows displayed, I just need to modify one of the filter values. With that said I would say that I need to change the existing SQL script.

Thanks