Results 1 to 5 of 5

Thread: [RESOLVED] KeyPress problem

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2005
    Location
    Phoenix, Arizona
    Posts
    34

    Resolved [RESOLVED] KeyPress problem

    Hello,
    I have a problem in following sub:
    VB Code:
    1. Private Sub Form_KeyPress(KeyAscii As Integer)
    2.   If KeyAscii = 19 Then
    3.     If cmdSave.Enabled = True Then
    4.       cmdSave_Click
    5.     End If
    6.     MsgBox KeyAscii  'Trying to figure out this....
    7.   Else
    8.     mbDirty = True
    9.     Call CheckButtons
    10.   End If
    11.  
    12. End Sub

    I have ctrl+s key combination saving current recordset on the form. Everything is fine except when focus is on ComboBox and I try ctr+s, it brings item in ComboBox list starting with letter "s".
    I tried to put similar code in keyup event, but result is the same.
    Please help.

    Deki PA

  2. #2

    Thread Starter
    Member
    Join Date
    Nov 2005
    Location
    Phoenix, Arizona
    Posts
    34

    Re: KeyPress problem

    Just one more note...
    VB Code:
    1. MsgBox KeyAscii 'Trying to figure it out....
    with this in code it works fine, but I don't want this msgbox to pop-up.

  3. #3
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: KeyPress problem

    VB Code:
    1. If KeyAscii = 19 Then
    2.     If cmdSave.Enabled = True Then
    3.       cmdSave_Click
    4.       [B]KeyAscii = 0[/B]
    5.     End If

  4. #4
    Addicted Member o0yuna0o's Avatar
    Join Date
    Mar 2006
    Posts
    172

    Re: KeyPress problem

    try this in Form_keydown event... im using this on my program... but i use F2 in saving

    the ctrl + s would be

    (Shift = 2 and Keycode = 83)

    VB Code:
    1. If (KeyCode = 113) Then
    2.      cmdSave_Click
    3. End If

    Note: don't forget to set the Form Keypreview Property into True

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2005
    Location
    Phoenix, Arizona
    Posts
    34

    Re: KeyPress problem

    Quote Originally Posted by bushmobile
    VB Code:
    1. If KeyAscii = 19 Then
    2.     If cmdSave.Enabled = True Then
    3.       cmdSave_Click
    4.       [B]KeyAscii = 0[/B]
    5.     End If
    Thank you all. I used Bushmobile's code above, just moved KeyAscii = 0 below End If in my case. Works great!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width