reox
reox

Reputation: 5217

Select String in odbc query

is there any posibility to select a string in an odbc query? i want select the sum of many excel sheets and also need the name of the excel sheet in the resulting pivottable, so i tried something like this:

strSQL = "SELECT Sum(`table" & i & "`.`Stunden`), " & GetFilenameFromPath(arrFiles) & " FROM [" & strSheet & "$] `table" & i & "` WHERE `table" & i & "`.`Stunden` IS NOT NULL"

but the select statement " & GetFilenameFromPath(arrFiles) & " does not work right... a select of 1 works instead! e.g:

strSQL = "SELECT Sum(`table" & i & "`.`Stunden`), 1 FROM [...]

do i have to escape the string in any form?

thanks

Upvotes: 0

Views: 1069

Answers (1)

Mutation Person
Mutation Person

Reputation: 30498

Well, GetFilenameFromPath will return you a string, so you need to encase this in quotes:

strSQL = "SELECT Sum(`table" & i & "`.`Stunden`), '" & GetFilenameFromPath(arrFiles) & "' FROM...

Although, I'd encourage you to be more explicit in your question. Details of the expected output of GetFilenameFromPath for you, and a specific error message would be very helpful.

Upvotes: 1

Related Questions