Untested but should work:
<cfquery name="getPhysicianRecords" datasource="#DSN#">
SELECT * FROM Contacts
WHERE Contacts.ContactType = 'Physician'
<cfif Len(form.field) AND StructKeyExists(form,form.field)>
AND Contacts.#FORM.Field# = '#Trim(form[form.field])#'
<cfelse>
1 = 0
</cfelse>
ORDER BY Contacts.LastName
</cfquery>
CF evaluates inside->out so form.field is resolved (doesn't need quotes
because its a variable) to a string that is used in the form struct to refer
to that particular key. The rest of the code I added in is for error
handling and it should probably go in a cfqueryparam as well.
Cheers,
Judah
On Wed, Sep 10, 2008 at 7:03 AM, David Moore, Jr. <[EMAIL PROTECTED]>wrote:
> Ray wrote:
>
> > As someone who used to always pounce on folks for using evaluate, I>
> believe I remember reading recently a blog entry from an Adobian that>
> points out that evaluate is not nearly as slow as it used to be.> > Now when
> I recommend against Evaluate I do so on readability terms> rather than
> performance. For almost every use of evaluate I see in the> field, the code
> can be rewritten in a cleaner, easier to understand> manner.
> How then would you approach the following without Evaluate, because it was
> the only way I could get it to work: (oh, let the fun begin, the shame. I
> probably committed at least 7 deadly sins alone. And yes, I am using Access.
> Moan. Laughter.) In my ever growing need to expand my knowledge base (and
> look less like an idiot to this list) HELP? It's a query that accepts
> information from a Search field to run a query.
>
> <cfquery name="getPhysicianRecords" datasource="#DSN#">SELECT *FROM
> ContactsWHERE Contacts.ContactType = 'Physician'
> AND Contacts.#FORM.Field# = '#Evaluate("FORM.#FORM.Field#")#'ORDER BY
> Contacts.LastName~David
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312335
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4