View Full Version : Search Form Help!


rschneid
07-26-2001, 09:56 AM
I recently created a form in my Access database that allows users to search the table. The users have five areas they can search from. The problem I'm having is you can only search by one field at a time. I have five seperate command (search) buttons for each text box. I would like it to search with one command button that takes the information from all five text/combo boxes. Is this possible? I've included my VBS for this particular form. Thanks in advance for your help!!

Private Sub Command2_Click()
On Error GoTo Err_cmdDoc_Click

Dim db As Database
Dim qry As QueryDef
Dim rst As Recordset
Dim tbl As TableDef
Dim tbl2 As TableDef
Dim rst2 As Recordset
Dim strTest As String
Set db = CurrentDb
Set qry = db.QueryDefs("qryDelFileNumbers")
DoCmd.RunSQL qry.SQL

Set tbl = db.TableDefs("tblLibrary")
Set rst = tbl.OpenRecordset(dbOpenDynaset)
Set tbl2 = db.TableDefs("tblFileNumbers")
Set rst2 = tbl2.OpenRecordset(dbOpenDynaset)
rst.MoveFirst
strTest = Trim(Description.Value)
Rem MsgBox strTest

Do While Not rst.EOF
If InStr(1, rst.Fields("Description"), strTest)

rst2.AddNew
rst2.Fields("File #") = rst.Fields("File #")
rst2.Update
End If
rst.MoveNext

Loop
Me![qryDocumentTitle subform].Requery

Exit_cmdDoc_Click:
Exit Sub

Err_cmdDoc_Click:
MsgBox Err.Description
Resume Exit_cmdDoc_Click
End Sub

Jack Cowley
07-26-2001, 02:08 PM
I think this article is what you are looking for...
http://support.microsoft.com/support/kb/articles/Q136/0/62.asp?LN=EN-US&SD=gn&FR=0&qry=q136062&rnk=1&src=DHCS_MSPSS_gn_SRCH&SPR=ACC97