This Keypress event purpose is to update a bound field called txtSentto after searching a table of values. Code works when i stop execution with a stop command or debug tag. Allow code to run uninterrupted, the field does not update with new value. Essentially trying to fill in the field while user is keying. The form also offers the user a list box where they can select the values. The users prefer to keep fingers on the keyboard and not have to scroll the list.
The event starts when user enters a valid alpha character. Expected results are, enter a "B", without the quotes, update field with "Book Orders,". Then enter "D" results in "Book Orders, Donations, ", etc. Code is simple. Please excuse the lack of good naming standards.
HldKey is the character keyed by the user. If user keys additional characters to improve result, the field holds all the keyed characters.
txtSentto is the bound text field, on the form, the code is updating.
Currently,
When user enters b or B, the field does not update so the user sees what they keyed rather than the expected result. When the 'Stop
command line is uncommented or stop execution with a debug tag on line 5, the field updates with the expected results.
The debug.print prints the expected results. txtSentto has the expected results value, but the form is not getting updated.
Very Stumped. Please help!!!!
X = 1
RecCountstl = 21 ' For testing, comment out for production.
Do While X < RecCountstl + 1
If HldKey = Left(SentToLoc(X), Len(HldKey)) Then 'Loaded table during load event.
txtSentto = SentToLoc(X) + ", "
Enclosures = txtSentto
Debug.Print txtSentto
HldKey = ""
Exit Do
End If
X = X + 1
Loop
'Stop
End Sub
Tried numerous approaches such as. I have compared field property settings to other working fields. Line 6, Enclosures, is another bound text field on the form i used for testing. The enclosures field updates properly in all circumstances, while the txtSentto field fails.
I have used the step into procedure to trace the code execution, used the Set Next statement at various points. The code appears to work perfectly, the txtSentto field on the form, is not displaying the expected results.
Is it possible that keypress event cannot update a form field as i am doing? I am replacing the entered character with value from the table. Maybe keypress is preventing this operation. Maybe stopping execution could be overriding the block built into the keypress event.