On Key Press Event

radek225

Registered User.
Local time
Today, 11:23
Joined
Apr 4, 2013
Messages
307
I have a code on my list
Code:
Private Sub Lista0_KeyPress(KeyAscii As Integer)
Dim strSQL As String
Dim db As DAO.Database
If KeyAscii = 50 Then
strSQL = "UPDATE tblZlecenia SET Priorytet = " & "7" & "  WHERE ID_Zlecenia='" & Me.Lista0 & "'"
  CurrentDb.Execute strSQL
End If

End Sub
When I press button "2" on my keyboard, my code is working (it's ok) but except this, changing selection on my list, to position where bound column starting from "2" character. What I should do, to not change possition on my list?
 
Try by setting KeyAscii=0.
Code:
Private Sub Lista0_KeyPress(KeyAscii As Integer) 
   Dim strSQL As String 
   Dim db As DAO.Database 
   If KeyAscii = 50 Then 
     strSQL = "UPDATE tblZlecenia SET Priorytet = " & "7" & "  WHERE ID_Zlecenia='" & Me.Lista0 & "'"   
     CurrentDb.Execute strSQL   
     KeyAscii=0
   End If  
End Sub
 
:D:D:D:D:D:D Working! THX!
 
You're welcome, good luck! :)
 

Users who are viewing this thread

Back
Top Bottom