Multiple criteria queries

Results 1 to 2 of 2

Thread: Multiple criteria queries

  1. #1
    Kevin D Guest

    Default Multiple criteria queries

    Does anyone know how to allow for multiple criteria queries of an Access database using asp and Frontpage98? I want to query by state, product category and cost with one query.

  2. #2
    Chad Franklin Guest

    Default RE: Multiple criteria queries

    This should do. Forgive me if there is some errors, but the logic seems right.<BR><BR><BR>HTML PAGE -- Prompt.htm<BR>&#060;html><BR><BR>&#060;head><BR>&# 060;title>Prompt&#060;/title><BR>&#060;/head><BR><BR>&#060;body><BR><BR>&#060;form METHOD="GET" ACTION="Prompt.ASP"><BR> &#060;p>[Enter State] &#060;input TYPE="Text" NAME="[Enter State]" size="20">&#060;/p><BR> &#060;p>[Enter Product] &#060;input TYPE="Text" NAME="[Enter Product]" size="20">&#060;/p><BR> &#060;p>[Enter Category] &#060;input TYPE="Text" NAME="[Enter Category]" size="20">&#060;/p><BR>&#060;p>[Enter Cost] &#060;input TYPE="Text" NAME="[Enter Cost]" size="20">&#060;/p><BR><BR> &#060;p>&#060;input TYPE="Submit" VALUE="Run Query"> &#060;/p><BR>&#060;/form><BR>&#060;/body><BR>&#060;/html><BR><BR><BR>ASP PAGE -- Prompt.asp<BR>&#060;html><BR><BR>&#060;head><BR>&# 060;meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=windows-1252"><BR>&#060;title>Prompt&#060;/title><BR>&#060;/head><BR><BR>&#060;body><BR>&#060;%<BR>Param = Request.QueryString("Param")<BR>Data = Request.QueryString("Data")<BR>&#037;&#062;<BR>&#0 60;%<BR>If IsObject(Session("Access_conn")) Then<BR> Set conn = Session("Access_conn")<BR>Else<BR> Set conn = Server.CreateObject("ADODB.Connection")<BR> conn.open "Access","",""<BR> Set Session("Access_conn") = conn<BR>End If<BR>&#037;&#062;<BR>&#060;%<BR> sql = "SELECT Table.State, Table.product, Table.category , Table.cost FROM Mailing WHERE (((Table.State)=" & Request.QueryString("[Enter State]") & ") AND ((Table.Product)=" & Request.QueryString("[Enter Product]") & ") AND ((Table.Category)=" & Request.QueryString("[Enter Category]") & ") AND ((Table.cost)=" & Request.QueryString("[Enter Cost]")) & ") "<BR> If cstr(Param) &#060;> "" And cstr(Data) &#060;> "" Then<BR> sql = sql & " And [" & cstr(Param) & "] = " & cstr(Data)<BR> End If<BR> Set rs = Server.CreateObject("ADODB.Recordset")<BR> rs.Open sql, conn, 3, 3<BR>&#037;&#062;<BR><BR>&#060;table BORDER="1" BGCOLOR="#ffffff" CELLSPACING="0"><BR> &#060;font FACE="Arial" COLOR="#000000">&#060;caption>&#060;b>Prompt&#060;/b>&#060;/caption><BR>&#060;THEAD><BR> &#060;tr><BR> &#060;th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000">&#060;font SIZE="2" FACE="Arial" COLOR="#000000">State&#060;/font>&#060;/th><BR> &#060;th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000">&#060;font SIZE="2" FACE="Arial" COLOR="#000000">Product&#060;/font>&#060;/th><BR> &#060;th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000">&#060;font SIZE="2" FACE="Arial" COLOR="#000000">Category<BR> &#060;th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000">&#060;font SIZE="2" <BR>FACE="Arial" COLOR="#000000">Cost<BR> &#060;th BGCOLOR="#c0c0c0" BORDERCOLOR="#000000">&#060;font SIZE="2" <BR> &#060;/tr><BR>&#060;/THEAD><BR>&#060;TBODY><BR>&#060;%<BR>On Error Resume Next<BR>rs.MoveFirst<BR>do while Not rs.eof<BR> &#037;&#062;<BR> &#060;tr VALIGN="TOP"><BR> &#060;td BORDERCOLOR="#c0c0c0">&#060;font SIZE="2" FACE="Arial" COLOR="#000000">&#060;%=Server.HTMLEncode(rs.Field s("State").Value)&#037;&#062;<BR><BR> &#060;/font>&#060;/td><BR> &#060;td BORDERCOLOR="#c0c0c0">&#060;font SIZE="2" FACE="Arial" COLOR="#000000">&#060;%=Server.HTMLEncode(rs.Field s("Product").Value)&#037;&#062;<BR><BR> &#060;/font>&#060;/td><BR> &#060;td BORDERCOLOR="#c0c0c0">&#060;font SIZE="2" FACE="Arial" COLOR="#000000">&#060;%=Server.HTMLEncode(rs.Field s("Category").Value)&#037;&#062;<BR><BR>&#060;/font>&#060;/td><BR> &#060;td BORDERCOLOR="#c0c0c0">&#060;font SIZE="2" FACE="Arial" COLOR="#000000">&#060;%=Server.HTMLEncode(rs.Field s("Cost").Value)&#037;&#062;<BR><BR> &#060;/font>&#060;/td><BR> &#060;/tr><BR>&#060;%<BR>rs.MoveNext<BR>loop&#037;&#062;< BR>&#060;/TBODY><BR>&#060;TFOOT><BR>&#060;/TFOOT><BR>&#060;/table><BR>&#060;/font><BR>&#060;/body><BR>&#060;/html><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
  •