What your trying to do is possible, but you need to build a variable name first.
Instead of
<cfset test = variables.qry1. & variables.qry2.#valueID#>
Try
<cfset test = "variables.qry1.#variables.qry2.valueID#">
Test will then be variables.qry1.[valueID value]
. Note that [valueID value] is what is getting returned from the query, so the actual value inside the variable.
Then to display the value of variables.qry1.[valueID value]
.
#evaluate(test)#
UPDATE As stated by Adam Cameron's answer. You should really try to avoid the evaluate()
function, it's quite a performance hit and not considered good practice. Instead rather use the following code (This is copied from Adam Cameron's answer)
#variables.qry1[variables.qry2.valueID][1]#
NOTE: Go look at Adam Cameron's answer for a better description of whats going on.