keyword search

G

Guest

I am attempting to create a kewyord search, but am having a lot of
difficulities. I have a database of nearly 2000 properties. Some of these
properties have historic/common names which are stored as a single string on
the record. What I would like is to have the user be able to search the
database for any part of the string in a particular field. For example, one
property is called the Brunner Building, but is also know as the Old Library.
I would like the user to be able to search by entering any one of the words
Brunner, Building, Old, Library, etc. and the record would appear.
 
G

Guest

If you create a form bound to the table (or better still to a sorted query
based on the table so that the records are ordered logically), then add an
unbound text box, txtFindName say to the form, the form will be filtered to
record(s) with a value in a PropertyName field which contain the substring
when the user enters a substring in the text box and presses the return key
or moves off the text box in some other way. This is done by putting the
following code as the text box's AfterUpdate event procedure

Private Sub txtFindName_AfterUpdate()

If Not IsNull(txtFindName) Then
Me.Filter = "[PropertyName] Like ""*" & txtFindName & "*"""
Me.FilterOn = True
Else
Me.FilterOn = False
End If

End Sub

If the user deletes the value from the text box and presses return etc, the
filter will not be active and all records will be shown. This will probably
produce some unwanted records from time to time, e.g. if the user enters
'old' it would return any rows where the property name contained the
substring 'bold', 'cold' 'solder' etc.

Ken Sheridan
Stafford, England
 
G

Guest

So, how do I bound a query to form (or visa versa)?

Ken Sheridan said:
If you create a form bound to the table (or better still to a sorted query
based on the table so that the records are ordered logically), then add an
unbound text box, txtFindName say to the form, the form will be filtered to
record(s) with a value in a PropertyName field which contain the substring
when the user enters a substring in the text box and presses the return key
or moves off the text box in some other way. This is done by putting the
following code as the text box's AfterUpdate event procedure

Private Sub txtFindName_AfterUpdate()

If Not IsNull(txtFindName) Then
Me.Filter = "[PropertyName] Like ""*" & txtFindName & "*"""
Me.FilterOn = True
Else
Me.FilterOn = False
End If

End Sub

If the user deletes the value from the text box and presses return etc, the
filter will not be active and all records will be shown. This will probably
produce some unwanted records from time to time, e.g. if the user enters
'old' it would return any rows where the property name contained the
substring 'bold', 'cold' 'solder' etc.

Ken Sheridan
Stafford, England

ajwittman said:
I am attempting to create a kewyord search, but am having a lot of
difficulities. I have a database of nearly 2000 properties. Some of these
properties have historic/common names which are stored as a single string on
the record. What I would like is to have the user be able to search the
database for any part of the string in a particular field. For example, one
property is called the Brunner Building, but is also know as the Old Library.
I would like the user to be able to search by entering any one of the words
Brunner, Building, Old, Library, etc. and the record would appear.
 
G

Guest

Either create a form in design view and set the name of the query as the
form's RecordSource property, or use the form wizard and select the query in
the dialogue. Or you can select the query in the database window and select
Form from the Insert menu (or use the corresponding toolbar button), and then
select one of the options from the dialogue to build the type of form you
want. If you create an autoform you can subsequently open it in design view
and amend it, adding the text box and the code in its AfterUpdate event
procedure before saving it again.

Ken Sheridan
Stafford, England

ajwittman said:
So, how do I bound a query to form (or visa versa)?

Ken Sheridan said:
If you create a form bound to the table (or better still to a sorted query
based on the table so that the records are ordered logically), then add an
unbound text box, txtFindName say to the form, the form will be filtered to
record(s) with a value in a PropertyName field which contain the substring
when the user enters a substring in the text box and presses the return key
or moves off the text box in some other way. This is done by putting the
following code as the text box's AfterUpdate event procedure

Private Sub txtFindName_AfterUpdate()

If Not IsNull(txtFindName) Then
Me.Filter = "[PropertyName] Like ""*" & txtFindName & "*"""
Me.FilterOn = True
Else
Me.FilterOn = False
End If

End Sub

If the user deletes the value from the text box and presses return etc, the
filter will not be active and all records will be shown. This will probably
produce some unwanted records from time to time, e.g. if the user enters
'old' it would return any rows where the property name contained the
substring 'bold', 'cold' 'solder' etc.

Ken Sheridan
Stafford, England

ajwittman said:
I am attempting to create a kewyord search, but am having a lot of
difficulities. I have a database of nearly 2000 properties. Some of these
properties have historic/common names which are stored as a single string on
the record. What I would like is to have the user be able to search the
database for any part of the string in a particular field. For example, one
property is called the Brunner Building, but is also know as the Old Library.
I would like the user to be able to search by entering any one of the words
Brunner, Building, Old, Library, etc. and the record would appear.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top