I have a continuous form (set to "no edit"
displaying a list of people's names, in ascending order. I want a VBA code so that when I press a key, for example "J", the curser will go to the first record which its name starts with letter "J", for example "John". However, this is NOT a filter, since I just want the curser to go to position of "J" only, after that you can press up arrow to reach upper/previous records, or press another letter key to go for other names. This is the code I am writing, it is not working, why?
Private Sub Form_KeyPress(KeyAscii As Integer)
Dim TargetCode As String
DoCmd.GoToRecord , , acFirst
Do Until KeyAscii = TargetCode
TargetCode = Left(Name.Value, 1)
DoCmd.GoToRecord , , acNext
Loop
End Sub
I also want to know if I can add a "non-letter proof" feature, that is, to ignore any symbol input such as +,?,!,(,*..., but I want numbers to be allowed. Any ideas?
Private Sub Form_KeyPress(KeyAscii As Integer)
Dim TargetCode As String
DoCmd.GoToRecord , , acFirst
Do Until KeyAscii = TargetCode
TargetCode = Left(Name.Value, 1)
DoCmd.GoToRecord , , acNext
Loop
End Sub
I also want to know if I can add a "non-letter proof" feature, that is, to ignore any symbol input such as +,?,!,(,*..., but I want numbers to be allowed. Any ideas?