Apparently, ValueList() WILL NOT WORK with a dynamic column name! (Make sure to read all the way thru because I did find a work around, using another function.)

I have tried the following methods of using a dynamic column name in a Value list function and I continuously get an error returned to me.

view plain print about
1<cfscript>
2query_id_list = ValueList(evaluate( 'query.' & key_fieldname ));
3query_id_list = ValueList(evaluate( 'query.#key_fieldname#' ));
4query_id_list = ValueList( query[key_fieldname] );
5//key_fieldname a variable that is set, before this code executes, to the main id column of the query we are using
6
</cfscript>

After further research, I guess ValueList() will only work with a static column name, in this format:

view plain print about
1<cfscript>
2query_id_list = ValueList(query.main_id);
3//main_id being the actual name of the column in the table
4
</cfscript>

Here's a nice little work around to this dilemma:

view plain print about
1<cfscript>
2query_id_list = ArrayToList( query[key_fieldname] );
3//key_fieldname is still a variable that is set, before this code executes, to the main id column of the query we are using
4
</cfscript>
This will return exactly what the first group of code should.

I'm not entirely sure why Adobe wouldn't allow ValueList() to accept a dynamic column name. Any ideas?

'Til next time, Bridget