Results 1 to 5 of 5

Thread: Combo Boxes

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954

    Combo Boxes

    I am pulling some info from an access DB. I want to put some combo boxes to build a query to sort, how would I do that?

  2. #2
    sarun
    Guest
    This populates a combo box with the rows from a table. In this case the vallue of each item is the "Code" but the text displayed is from the "Desc" column.



    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open "select * from table1", cn
    If rs.EOF Then
    Else
    Response.Write "<br><b>Whatever: </b>&nbsp;<SELECT NAME=""WhateverName"" SIZE=5 " & " >"
    Do Until rs.EOF
    Response.Write "<OPTION VALUE=""" & rs("Code") & _
    """>" & rs("Desc") & "</OPTION>"
    rs.MoveNext
    Loop
    Response.Write "</SELECT><br>"
    End If
    rs.Close
    Set rs = Nothing

    hope this helps.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    Actually what I want to do is build a query from a selection in the combo box. I am going to display a page and then have a combo box to sort more specifically...So the page loads and then you select an item in the combo box and it reloads with a modified query,...Thanks

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    Anyone??

  5. #5
    Junior Member JohannS's Avatar
    Join Date
    Aug 2001
    Location
    Pretoria, South Africa
    Posts
    21
    This does what you want

    Private Sub Command1_Click()

    Dim searchstr as string
    searchstr = Combo1.Text

    datPrimaryRS.RecordSource = "Select name, surname, number from mytable where name = '" & searchstr & "'"
    datPrimaryRS.Refresh

    End Sub

    You can also of course put the code into combo1_change(), or something.

    The command1 button is simply a "Submit" button.
    It was an electrical problem sir, a conrod went through the block, and knocked the distributer off.

Posting Permissions

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



Click Here to Expand Forum to Full Width