G
Guest
Hi to all,
I have code that jumps to records that meet criterior of what's typed into a
text box. The way it's supposed to work is a user types a few characters in
the text box and any record(s) meeting the criterior become the current
record.
In my form I have several record fields including Last Name. I have a
separate text box "LookupLast" bound to the Last Name field. The problem is
when user types into LookupLast text box the Last Name field gets overwritten.
Can anyone look at code below and see what can be done to make it work!!
Below is VB code for LookupLast text box:
Option Compare Database
Option Explicit
Dim strFind As String
Dim datLastKeyPress As Date
Private Sub LookupLast_KeyPress(KeyAscii As Integer)
Dim strChr As String
strChr = Chr(KeyAscii)
If DateDiff("S", datLastKeyPress, Now) > 2 Then
strFind = strChr
Else
strFind = strFind & strChr
End If
DoCmd.FindRecord strFind, acStart, , , , , True
If Left(LookupLast, Len(strFind)) <> strFind Then
strFind = strChr
DoCmd.FindRecord strFind, acStart, , , , , True
End If
datLastKeyPress = Now
End Sub
I have code that jumps to records that meet criterior of what's typed into a
text box. The way it's supposed to work is a user types a few characters in
the text box and any record(s) meeting the criterior become the current
record.
In my form I have several record fields including Last Name. I have a
separate text box "LookupLast" bound to the Last Name field. The problem is
when user types into LookupLast text box the Last Name field gets overwritten.
Can anyone look at code below and see what can be done to make it work!!
Below is VB code for LookupLast text box:
Option Compare Database
Option Explicit
Dim strFind As String
Dim datLastKeyPress As Date
Private Sub LookupLast_KeyPress(KeyAscii As Integer)
Dim strChr As String
strChr = Chr(KeyAscii)
If DateDiff("S", datLastKeyPress, Now) > 2 Then
strFind = strChr
Else
strFind = strFind & strChr
End If
DoCmd.FindRecord strFind, acStart, , , , , True
If Left(LookupLast, Len(strFind)) <> strFind Then
strFind = strChr
DoCmd.FindRecord strFind, acStart, , , , , True
End If
datLastKeyPress = Now
End Sub