Searching form based on query

Abbos

Registered User.
Local time
Today, 00:33
Joined
May 11, 2005
Messages
64
Hi,

I have a form that is based on a query with many fields. As an example there is a field called "Medium" which contains values such as "Oil on canvas", "Oil on wood" etc.

At the moment I have a filter which works fine but this doesn't allow me to search all records which have the word "Oil" as part of the Medium.

I would like to be able to search all fields on the form. I have looked at a few exmaples on the forums but could not find one that applies to my scenario.

Can anyone help?

Thanks in advance.
 
I read that thread but the records are displayed in a different way and the search is also limited to a number of fieldnames.

I was hoping to find a snippet of code that I could use of the AfterUpdate event on each field on the form (textbox), so that as soon as a user starts to type something in the field it would search it.

Any ideas.. ?
 
As posted the query that populates the list box is based on only one input text box (that searches a number of fields). There is no reason you couldn't modify it so that the query is based on a number of text boxes that supply criteria to different fields within the query.
 
Hi Abbos,

Here is a sample from somewhere. I have lost the original web site where it come from.

Code:
Option Compare Database
Option Explicit

Private Sub ClearIt_Click()
On Error GoTo Err_ClearIt

Me.Search = ""
 Me.Search2 = ""
  Me.QuickSearch.Requery
   Me.QuickSearch.SetFocus

Exit_ClearIt_Click:
    Exit Sub

Err_ClearIt:
    MsgBox Err.Description
    Resume Exit_ClearIt_Click

End Sub

Private Sub QuickSearch_AfterUpdate()
    
DoCmd.Requery
Me.RecordsetClone.FindFirst "[Name] = '" & Me![QuickSearch] & "'"
If Not Me.RecordsetClone.NoMatch Then
   Me.Bookmark = Me.RecordsetClone.Bookmark
Else
   MsgBox "Could not locate [" & Me![QuickSearch] & "]"
End If

End Sub


Private Sub Search_Change()
Dim vSearchString As String

 vSearchString = Search.Text
 Search2.Value = vSearchString
 Me.QuickSearch.Requery

End Sub

ClearIt_Click is to clear the textbox.

QuickSearch is a listbox of the query on the search textbox.
You'll need to modify it.

Search is the search textbox on the OnChange event.


Abbos said:
I read that thread but the records are displayed in a different way and the search is also limited to a number of fieldnames.

I was hoping to find a snippet of code that I could use of the AfterUpdate event on each field on the form (textbox), so that as soon as a user starts to type something in the field it would search it.

Any ideas.. ?
 

Users who are viewing this thread

Back
Top Bottom