Results 1 to 4 of 4

Thread: Making a Search Button

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Location
    Rio Rancho, NM
    Posts
    21
    I am trying to make a search button feature. I have 1 combo box and one text box. I need to use these two boxes in order to perform a search in my database. The combo box is going to be the columns and the text is what is going to be in the fields. How Do I create something like that?

    Joe

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    I assume you are already working with a database, so here is a basic layout to try. I am using ADO with this code:

    Code:
    Private Sub Command1_Click()
    Dim rs As New Recordset
    Dim csql As String
    csql = "SELECT * FROM table where " & Combo1.Text & " LIKE %" & Text1.Text & "%"
    rs.Open csql, db, adOpenForwardOnly, adLockReadOnly
    End Sub
    
    Private Sub Form_Load()
    Dim rs As New Recordset
    Dim csql As String
    csql = "SELECT * FROM table"
    rs.Open csql, db, adOpenForwardOnly, adLockReadOnly
    Dim i As Integer
    For i = 0 To rs.Fields.Count - 1
      Combo1.AddItem rs.Fields(i).Name
    Next
    
    End Sub
    Hope this helps

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Location
    Rio Rancho, NM
    Posts
    21
    Why do I want to open the database again when I am already using it? Maybe I am missing something. My database is already open. They click a button to go to a search box with a drop down box and a text field. They type in the info they want and click search. Then the form should disappear and the information they selected should be back on the orginal screen they were looking at.

    joe

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Location
    Rio Rancho, NM
    Posts
    21
    ttt
    Joe
    Rio Rancho, NM
    Bank of America
    Telecomm Analyst
    [email protected]

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