Search field for not exact entry

P

Pamela

I'd like to have a button to duplicate on my form the Find function that
Access with the ability to search "Any Part of Field" the same way. So if I
have owner Mayco Bldg Systems, the user can simply type Mayco and it will
find the appropriate record. Right now, the user has to have the exact name
for the system to find it. Thanks for any help! Pamela
 
J

Jeff Boyce

Pamela

I'm not clear on how/where this is happening, other than you mention a form.

One approach to having users find a specific record is to use a combobox,
letting them select the correct one.

Another is to use a query with the "*" wildcard character ... the Selection
Criterion for that field might look something like:

Like * & [Enter your search string] & *

This has the effect of looking for the search string entered anywhere within
the field. (Check Access HELP re: wildcards & queries)

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
P

Pamela

Jeff,

That looks great...the wildcard Like code... but I have no idea how to
implement it...Here is my code (copied from someone else) for the cmdbutton
on my form (the same form that contains the control it's searching).
How/where might I fit that in? Thanks so much! Pamela

Private Sub Command102_Click()
Dim strSearch As String
Dim rs As Object
Set rs = Me.RecordsetClone
strSearch = InputBox("Please enter the Owner's Name:")
With rs
..FindFirst "[Owners Name] = '" & strSearch & "'"
If .NoMatch Then
MsgBox strSearch & " not found!"
Else
Me.Bookmark = .Bookmark
End If
End With
rs.Close
Set rs = Nothing
End Sub

Jeff Boyce said:
Pamela

I'm not clear on how/where this is happening, other than you mention a form.

One approach to having users find a specific record is to use a combobox,
letting them select the correct one.

Another is to use a query with the "*" wildcard character ... the Selection
Criterion for that field might look something like:

Like * & [Enter your search string] & *

This has the effect of looking for the search string entered anywhere within
the field. (Check Access HELP re: wildcards & queries)

Regards

Jeff Boyce
Microsoft Office/Access MVP

Pamela said:
I'd like to have a button to duplicate on my form the Find function that
Access with the ability to search "Any Part of Field" the same way. So if
I
have owner Mayco Bldg Systems, the user can simply type Mayco and it will
find the appropriate record. Right now, the user has to have the exact
name
for the system to find it. Thanks for any help! Pamela
 
J

Jeff Boyce

Pamela

Again, in place of the command button, consider using a combobox that lets
the user select the correct record.

The code you gave is looking for an exact match. If you want to use the
"Like ... " wildcard, you need to change that line that involves the
"FindFirst" statement. (and the combobox is the easier approach!).

Regards

Jeff Boyce
Microsoft Office/Access MVP


Pamela said:
Jeff,

That looks great...the wildcard Like code... but I have no idea how to
implement it...Here is my code (copied from someone else) for the
cmdbutton
on my form (the same form that contains the control it's searching).
How/where might I fit that in? Thanks so much! Pamela

Private Sub Command102_Click()
Dim strSearch As String
Dim rs As Object
Set rs = Me.RecordsetClone
strSearch = InputBox("Please enter the Owner's Name:")
With rs
.FindFirst "[Owners Name] = '" & strSearch & "'"
If .NoMatch Then
MsgBox strSearch & " not found!"
Else
Me.Bookmark = .Bookmark
End If
End With
rs.Close
Set rs = Nothing
End Sub

Jeff Boyce said:
Pamela

I'm not clear on how/where this is happening, other than you mention a
form.

One approach to having users find a specific record is to use a combobox,
letting them select the correct one.

Another is to use a query with the "*" wildcard character ... the
Selection
Criterion for that field might look something like:

Like * & [Enter your search string] & *

This has the effect of looking for the search string entered anywhere
within
the field. (Check Access HELP re: wildcards & queries)

Regards

Jeff Boyce
Microsoft Office/Access MVP

Pamela said:
I'd like to have a button to duplicate on my form the Find function
that
Access with the ability to search "Any Part of Field" the same way. So
if
I
have owner Mayco Bldg Systems, the user can simply type Mayco and it
will
find the appropriate record. Right now, the user has to have the exact
name
for the system to find it. Thanks for any help! Pamela
 

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