Posted on 2006-05-07
I have a program which looks up a value in a datbase and find the corresponding value and places it into another text box. It is fired by the press of the spacebar, this works fine but i was wondering if i could make it fire using the full stop, comma and so forth. i tried adding extra values keyascii part but when the spacebar was pressed after the full stop it changed back.
here is the code
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Dim Prts() As String
Dim tmpTEXT As String
If KeyAscii = 32 Then
If TextBox1.Text <> "" Then
tmpTEXT = TextBox1.Text
Prts = Split(TextBox1.Text, " ")
For X = 0 To UBound(Prts)
rs.FindFirst "[SearchText]='" & Prts(X) & "'"
If Not rs.NoMatch Then
tmpTEXT = Replace(tmpTEXT, Prts(X), rs.Fields("ReplacementText"))
TextBox2.Text = tmpTEXT
TextBox2.Text = Replace(tmpTEXT, Chr(9), " ")