Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query to Excel

Status
Not open for further replies.

ibsuntan

MIS
Dec 11, 2002
10
US
Hi all,
New here, very helpful board.
My question is .. got a query sending to Spreadsheet, I want to create a new column if I match a certain criteria,
Do I create if and then statement? or try to create a "like'statement?.
if application name = "MC\*" ...then create column name "Action" any time that the query finds MC\ I need the word ADD in the Action column of the speadsheet.
I know this is pretty vage, but any help wil be appreciated.
Thanks
Gregg
 
If you are doing this in code, create your SQL statment inside two or more variables.

Dim strSelect as String
Dim strRest as String

Assign the standard statement to the variables:
strSelect = "SELECT Exp1, Exp2, ..."
strRest = "FROM table1 WHERE X=Y, ..."

Then perform your test and add the column if you need to
If Mid(ApplicationName,1,3) = "MC\" Then
strSelect = strSelect & ", 'ADD' As Action"
Else
'Leave the query alone
End If

Then execute and send to your spreadsheet.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top