Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i setup a search tool on each field on a form

Status
Not open for further replies.

Malta393

Technical User
Apr 8, 2002
18
EU
My users want the facility to do a search on each field on their input forms bt typing in text,numbers etc and it answering with the records that match and telling them how many records meet their input

Any Clues on how this can be setup on a form??


I am at a loss

Will someone save me---please

 
Are you having one button search all the fields?

I've searched records using FindFirst with recordsets. The following is a summary of how you might do it.

Dim rst As Recordset
Dim bmk As Bookmark
Dim cnt As Long

Set rst = Me.RecordsetClone OR Set rst = Currentdb.OpenRecordset(<source recordset>)
cnt = 0

On Error GoTo ... 'error trap for blank recordset
rst.MoveFirst
rst.FindFirst &quot;<text field> = '&quot; & <criteria> & &quot;' OR <number field> = &quot; & <criteria> & &quot; OR <date field> = #&quot; & <criteria> & &quot;#&quot;

If Not rst.NoMatch Then
bmk = rst.Bookmark 'I'm not sure if you need Set here
End If

While Not rst.NoMatch
cnt = cnt + 1
rst.FindNext &quot;<text field> = '&quot; & <criteria> & &quot;' OR <number field> = &quot; & <criteria> & &quot; OR <date field> = #&quot; & <criteria> & &quot;#&quot;
Wend

MsgBox cnt & &quot; records found.&quot;
 
Should I set this up on a Button on a blank version of the form or can the button be added to the input form and users
just type their criteria into the text boxes.

PS-New to Access and vb NOVICE.

Sorry to be a bleb!!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top