Results 1 to 5 of 5

Thread: why is form_keypress firing twice?

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2003
    Posts
    56

    why is form_keypress firing twice?

    I have the keypreview to be true. Now whenever I press a key the form_keypress event is firing twice and giving me multiple values. I used a scanner , still getting multiple keys.
    Any idea whats wrong?

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    when you stop through your code.. is the keypress event being called for the second time before the first run through the event finishes?

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2003
    Posts
    56
    yes.As soon as it finishes the first time it goes into keypress event one more time.

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    can you post the code?

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2003
    Posts
    56
    Here is the code:

    Private Sub Form_KeyPress(KeyAscii As Integer)
    strcmd = strcmd & Chr(KeyAscii)
    'If this is a cmd and not a barcode, skip the class.
    If Len(strcmd) = 5 And Right(strcmd, 1) = "|" Then
    'There is a pipe in the 5th character. Is this too short to be a barcode
    If Mid(strcmd, 1, 2) = "11" Then
    'this is a cmd
    CmdProcessor (Mid(strcmd, 1, Len(strcmd) - 1))
    End If
    strcmd = ""
    Exit Sub
    End If
    End Sub

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