PDA

Click to See Complete Forum and Search --> : Making a Search Button


Jbajin
Jul 6th, 2000, 11:31 AM
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

Negative0
Jul 6th, 2000, 11:56 AM
I assume you are already working with a database, so here is a basic layout to try. I am using ADO with this 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

Jbajin
Jul 6th, 2000, 12:49 PM
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

Jbajin
Jul 7th, 2000, 09:20 AM
ttt