Populating one list box from another.

Results 1 to 2 of 2

Thread: Populating one list box from another.

  1. #1
    Join Date
    Dec 1969

    Default Populating one list box from another.

    I have a need to break down a very large recordset for diplay in a list box. The requirement is to select a region from the first listbox run a query based upon this selection and return branch addresses for that region to a second list box on the same page.<BR><BR>Is it even possible? If so, please help. You can email mello@iafrica.com

  2. #2
    ts_abbott@hotmail.com Guest

    Default RE: Populating one list box from another.

    Hi.<BR><BR>Yeah, this is possible.<BR><BR>For example....<BR><BR>&#060;%<BR> RegionId = Request("RegionId")<BR><BR> Dim Conn, DSN, SQL, Rs<BR><BR> Set Conn = Server.CreateObject("ADODB.Connection")<BR> DSN = "DSN=MyDB;UID=;PWD;"<BR> Conn.Open DSN<BR><BR> If Len(RegionID) &#062; 0 Then<BR><BR> &#039;Build the listbox with branch addresses.<BR><BR> SQL = "SELECT * FROM Branches WHERE RegionID=" & RegionID<BR> Set Rs = Conn.Execute(SQL)<BR><BR> Response.Write("&#060;SELECT NAME=Branches&#062;" & vbCrLf)<BR><BR> While Not Rs.EOF<BR> Response.Write(" &#060;OPTION VALUE=" & Rs("ID") & "&#062;" & Rs("BranchName") & "&#060;/OPTION&#062;" & VbCrLf)<BR> Rs.MoveNext<BR> Wend<BR><BR> Response.Write("&#060;/SELECT&#062;" & vbCrLf)<BR><BR> Rs.Close()<BR> Set Rs = Nothing<BR><BR> Else<BR><BR> Response.Write("&#060;FORM ACTION=thispage.asp METHOD=post&#062;" & vbCrLf)<BR> <BR> &#039;Write out your listbox with regions.<BR> Name your lisbox "RegionId"<BR> <BR> Response.Write("&#060;/FORM&#062;" & vbCrLf)<BR><BR> End If<BR><BR>Conn.Close()<BR>Set Conn = Nothing<BR><BR>Hope this helps.....<BR><BR>%&#062;

Posting Permissions

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