Search Engine in text

  • Thread starter Thread starter GW
  • Start date Start date
G

GW

Hi I have posted this before but Someone were not very
helpful and left me with very little information.

I need a search engine for textbox like combo box that put
possible match and autofill the field. Like this

Tablet:
Gear
Geek
----------
In Textbox you type Ge and then the search engine get
first possible match and autofills the field with "Gear"
If you were not going to type a word of a computerized
possible match and you add one more letter 'Gee' and then
computer give you the a possible match is Geek.

Thank you for your help in advance
 
Hi,
I'll give you something to start with. It's not perfect
but it seems to do the job:

Step by step
1) put this in the declarations section of your form's module:
Dim chrCount As Integer
Dim rs As DAO.Recordset

2) set the form's Key Preview property to Yes

3)In your text box's Key Press event put this:
'8 is backspace
If KeyAscii = 8 And chrCount <> 0 Then
chrCount = chrCount - 1
Else
chrCount = chrCount + 1
End If

4)in your text box's Key Up event put this:
rs.FindFirst "yourField Like '" & Left(Me.Text14.Text, chrCount) & "*'"
If Not rs.NoMatch Then
Me.Text14 = rs!fName
End If

Me.Text14.SelStart = chrCount
Me.Text14.SelLength = Len(rs!fName) - chrCount

5) in your form's Load event put this:
Set rs = CurrentDb.OpenRecordset(yourTable,dbOpenDynaset)

6) in your form's Close event put this:
Set rs = Nothing

Substitute your text box's name for Text14,the actual table name for yourTable and
your field name for yourField.

The backspace is a bit wonky sometimes but you should be able to tweak this
to suit your needs, although I would just use a combo box :-)
 
Back
Top