Skip to main content
Inspiring
July 17, 2009
Answered

Multiple Queries in same data-entry form

  • July 17, 2009
  • 1 reply
  • 1377 views

I hope I'm in the correct forum!

I am working on a data-entry screen that interfaces with a database for pre-determined entries.  The user will select the member's last name, no problem here, then using that last name, be given a list of first names that match the last name.  Here's what I have so far:

<CFQUERY DATASOURCE="cfissues" Name="LNameQry">

     SELECT LastName

        FROM Members

     ORDER BY LastName

</CFQUERY

<CFQUERY DATASOURCE="cfissues" Name="FNameQry">

     SELECT FirstName

        FROM Members

      WHERE LastName = #LastName#    ('#LastName#') (#FORM.LastName#)

</CFQUERY

<!--- ================== --->

<CFSELECT NAME="LastName"

                    QUERY = "LNameQry"

                    VALUE= "Value"

                    etc.

</CFSELECT>

The user selects a Member Last Name.  Using this Last Name, I would like to execute the FNameQry query that retrieves all the first names that match that last name chosen by the CFSELECT statement.  That way, the dropdown box for the First Name field contains only the qualifying names (not all 7,000 on the database!).  I've more to do beyond that, but just getting this first part to work would be a major accomplishment.

I've used varous combinations of the last name selected by the CFSELECT to execute FNameQry, but nothing seems to work.  I keep getting an error on LASTNAME not defined.

I guess I need to (somehow) define a variable that would be populated with the value selected in the CFSELECT statement and use that in the FNameQry?

    This topic has been closed for replies.
    Correct answer Dileep_NR

    hi

    use isdefined("form.LastName") for FNameQry

    1 reply

    Dileep_NR
    Dileep_NRCorrect answer
    Inspiring
    July 20, 2009

    hi

    use isdefined("form.LastName") for FNameQry