Form Objects, Dynamic SQL Query

Results 1 to 2 of 2

Thread: Form Objects, Dynamic SQL Query

  1. #1
    Join Date
    Dec 1969

    Default Form Objects, Dynamic SQL Query

    Friends, I have a table of plant species information I would like to query from a page which has check boxes with different plant characteristics (i.e. PH etc.)<BR><BR>I can&#039;t figure out how to write a SQL query which will take each checkbox value from the page and select only records which contain ALL of the selected check boxes. There&#039;s no AND OR statement! Here&#039;s the SQL: The two and three letter "NA" etc are the incoming checkbox values from the form.<BR><BR>SELECT ID<BR>FROM tblSpecies<BR>WHERE (incomingzone BETWEEN tblSpecies.MinZone and tblSpecies.MaxZone) AND (NA= incomingNA AND DR=incomingDR AND incomingLO=LO AND incomingOC=OC AND incomingSS=SS AND incomingSP=SP AND incomingSH=SH AND incomingUR=UR AND incomingWI=WI AND incomingWT=WT AND incomingP45=P45 AND incomingP50=P50 AND incomingP75=P75)<BR><BR>WHAT ABOUT BUILDING A DYANAMIC QUERY BASED ON ONLY THE BOXES TICKED OFF FROM THE FORM????<BR><BR>ANY HELP WOULD BE GLADLY APPRECIATED

  2. #2
    Heaven's Martini Guest

    Default basic dynamic sql (in vbscript)

    sure.<BR><BR>dim sql<BR><BR>sql = "select beerisgood from reality where beer=&#039;import&#039; "<BR><BR>&#039; **** this will work to get you all that have been checked providing checkbox name is same for all.<BR>sql = sql & " AND brand IN &#039;"& request("chkbox") &"&#039;"<BR><BR>or<BR>if (request("chkbox") = &#039;Bass&#039;) then<BR> sql = sql & " ...."<BR>end if<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts