Need guidance and code to search an Access 2000 database for part of a word.
I know enough that you have to somehow implement InStr but dont know how to
do this. Code I have only returns if fall String is found.
Private Sub Command1_Click()
Dim search As String
search = InputBox("Enter Index", search)
Data1.Recordset.Index = "Index"
Data1.Recordset.Seek "=", search
If Data1.Recordset.NoMatch Then
Data1.Recordset.MoveFirst
End If
End Sub
Thanks in advance
> Need guidance and code to search an Access 2000 database for part of a word.
> I know enough that you have to somehow implement InStr but dont know how to
[quoted text clipped - 11 lines]
>
> Thanks in advance
First of all, if you have a new question to ask, send it as
a new post, not as a reply to a post from six weeks ago.
You'll get more response. While you are at it, make the
title "Seach for Partial Word" or something more descriptive
than "Newbie Help".
Now to the question.
The simpliest way in your case will be to use FindFirst
instead of Seek. This means not using the index, but the
index won't help much for a partial word search anyway. (By
the way, "Index" is a terrible name for a field).
So replacing
> Data1.Recordset.Index = "Index"
> Data1.Recordset.Seek "=", search
with
Data1.Recordset.FindFirst "[Index] Like '*" & search &
"*'"
should work.
Andy Pandy - 30 Oct 2004 20:06 GMT
Only joined group last week so don't know of any previous question of 6
weeks ago, sorry.
Many thanks for the help and will put a more descriptive header in the
future.
Kind regards and thanks
Andy
>> Need guidance and code to search an Access 2000 database
> for part of a word.
[quoted text clipped - 34 lines]
> "*'"
> should work.
Steve Gerrard - 30 Oct 2004 23:22 GMT
| Only joined group last week so don't know of any previous question of 6
| weeks ago, sorry.
[quoted text clipped - 5 lines]
|
| Andy
Actually my mistake. Apparently all posts with the subject "Newbie Help"
get listed by Outlook Express as replies to the oldest "Newbie Help"
post in my local list - in this case, one from Sep 18. On Google, they
are all listed together, dating back to 1997! Still, it is probably more
useful for other readers to describe the problem briefly in the subject
line.