Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Multiple Select Listbox


Message #1 by "Young, Ashley" <Ashley.Young@c...> on Fri, 15 Nov 2002 10:35:16 -0500
I have an asp page that has six multiple selection list boxes on it. How do
I construct an ASP recordset query based on the multiple selections/single
selections from each listbox? (All six list boxes will be part of the same
query)

Any help or tutorial pages would be GREATLY appreciated!

--Ashley

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.377 / Virus Database: 211 - Release Date: 7/15/2002
 
Message #2 by "Larry Woods" <larry@l...> on Fri, 15 Nov 2002 09:12:38 -0700
First, write a short ASP page that will display the values
returned from a multiple select box.  This is the best way to
understand what is happening.

The selections from a multiple select box will come to the ASP
page as a string of comma-delimited values.  If you are lucky the
values that you have defined are numbers.  If this is the case,
you can use the "In (" predicate in a SQL statement to retrieve
values from the database.  On the other hand, if the values
returned are text values, then you will have to add "'" around
each value in the list.  Takes some more coding.

Best to start with the "test page" that I recommended above, then
go from there.

Hope this helps...

Larry Woods


> -----Original Message-----
> From: Young, Ashley [mailto:Ashley.Young@c...]
> Sent: Friday, November 15, 2002 8:35 AM
> To: Access ASP
> Subject: [access_asp] Multiple Select Listbox
>
>
> I have an asp page that has six multiple selection
> list boxes on it. How do
> I construct an ASP recordset query based on the
> multiple selections/single
> selections from each listbox? (All six list boxes will
> be part of the same
> query)
>
> Any help or tutorial pages would be GREATLY appreciated!
>
> --Ashley
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.377 / Virus Database: 211 - Release Date:
> 7/15/2002
>
>
>

Message #3 by "Charles Mabbott" <aa8vs@m...> on Fri, 15 Nov 2002 15:13:43 -0500
This is taken from an example in book....
It allowed me to pick various fields from the record
and display them...

Regards,
Chuck

<snip>
<!-- #INCLUDE FILE="RecToTable.asp" -->
<HTML>
<HEAD>
<TITLE>Find Member I94</TITLE>
</HEAD>
<BODY>

  Dim strSQL            ' SQL String
  Dim objRS, objField   ' ADO Recordset and Field objects
  Dim intCount          ' number of fields selected
  Dim vbQuote           ' quote character
  vbQuote = Chr(34)

  Response.Write "<H2>Find Member by Call</H2>"

  ' Check whether the user has checked any boxes to select some fields.
  ' If so, we'll display a table of data
  If Request.Form("Field").Count > 0 Then
    ' Find out which fields are to be selected
    strSQL = ""
    For intCount = 1 to Request.Form("Field").Count
      strSQL = strSQL & Request.Form("Field")(intCount) & ", "
    Next

    ' Strip the trailing comma and space (added in the loop) from end of 
strSQL
    strSQL = Left(strSQL, Len(strSQL) - 2)

    ' Add the SELECT command and the FROM criteria
    strSQL = "SELECT " & strSQL & " FROM members"

    ' If user requested a particular member, add a WHERE clause
    ' (otherwise they'll get data for all members)
    If Request.Form("Director") <> "" Then
      strSQL = strSQL & " WHERE callid LIKE '" & Request.Form("Director") & 
"'"
    End If

    ' Create the recordset
    Set objRS = Server.CreateObject ("ADODB.Recordset")
    objRS.Open strSQL, strConnect, adOpenForwardOnly, adLockReadOnly, 
adCmdText

    ' Write a table of the recordset
    Response.Write RecToTable (objRS)

    ' Clean up
    objRS.Close
    Set objRS = Nothing
  End If


<FORM NAME=MemberInfo ACTION="FindBycall.asp" METHOD="POST">
  Enter the Call sign to find:
  <INPUT TYPE="TEXT" NAME="Director"><BR><BR>

  Please select which fields you would like review :<BR>

    ' Create a recordset on the Members table
    Set objRS = Server.CreateObject ("ADODB.Recordset")
    objRS.Open "Members", strConnect, _
                    adOpenForwardOnly, adLockReadOnly, adCmdTable

    ' Create a checkbox in the form for each field in the recordset
    For Each objField in objRS.Fields
      Response.Write "<INPUT TYPE=CHECKBOX NAME=" & vbQuote & "Field" & 
vbQuote & _
                     " VALUE=" & vbQuote & objField.Name & vbQuote & ">" & _
                     objField.Name
    Next
    objRS.Close   ' clean up
    Set objRS = Nothing

  <BR><INPUT TYPE=SUBMIT VALUE="Find"><INPUT TYPE=RESET VALUE="Clear">
</FORM>
<center>

<h3>Last update: 9/22/01</h3>
</BODY>
</HTML>



"Whoever said the pen is mightier than the
sword obviously never encountered automatic
weapons."

http://68.43.100.7:81/aa8vs





>From: "Young, Ashley" <Ashley.Young@c...>
>Reply-To: "Access ASP" <access_asp@p...>
>To: "Access ASP" <access_asp@p...>
>Subject: [access_asp] Multiple Select Listbox
>Date: Fri, 15 Nov 2002 10:35:16 -0500
>
>I have an asp page that has six multiple selection list boxes on it. How do
>I construct an ASP recordset query based on the multiple selections/single
>selections from each listbox? (All six list boxes will be part of the same
>query)
>
>Any help or tutorial pages would be GREATLY appreciated!
>
>--Ashley
>
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.377 / Virus Database: 211 - Release Date: 7/15/2002
>
>


_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail


  Return to Index