Announcement

Collapse
No announcement yet.

[Solved] KeyDown vs KeyPress Events

Collapse
This topic is closed.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Solved] KeyDown vs KeyPress Events

    I have a form in which there are multiple listbox controls. On some of the controls I wanted to allow the user to change the order of selected items. To do this I didn't want extra buttons so I'm trying to use the KeyDown event.

    In order for the user to move a selection up or down the user was to use the Up/Down arrow keys in conjunction with the shift key. Hence I have to use the KeyDown.

    The following is the KeyDown code:

    Private Sub lboUpdWkStation_SelOps_KeyDown(ByVal KeyCode As MSForms.ReturnIntege
    r, ByVal Shift As Integer)
    '
    ' Me.txtUpdWkStation_UpdateName = ""
    ' Me.txtUpdWkStation_UpdateName = "Shift : " & Shift & " --- KeyCode" & K
    eyCode
    '
    '' Step 1 : Holding the shift key indicates user wants to change the order of
    selections
    ' If Shift = 1 Then
    ' If KeyCode = 38 Then Call MoveEntry(Me.lboUpdWkStation_SelOps, "UP")
    ' If KeyCode = 40 Then Call MoveEntry(Me.lboUpdWkStation_SelOps, "DOWN")
    ' End If
    '
    '' Step 2 : Ctrl - A = select all ; Ctrl -U = deselect all
    ' If Shift = 2 Then
    ' If KeyCode = 65 Then Call SelectAllItems(Me.lboUpdWkStation_SelOps, True)
    ' If KeyCode = 85 Then Call SelectAllItems(Me.lboUpdWkStation_SelOps, False)
    ' End If
    '
    End Sub

    The problem:
    I've found that when the user opens, to include me, the project and at the desired point tries to indicate he/she wants to adjust the order of the entries the form is not registering the KeyDown events. I've also noticed that the Up/Down arrows are not moving the selection indicator either.

    Now if I go into code to either place a MsgBox or step through the code it works as it should.

    The question is:
    Is there something going on in which events are not automatically triggered?
    Regards,
    Barry

    My Favorite New Thing:
    Dynamic Named Ranges



    The alternative for
    "Press Any Key To Continue."

    and we all have one we'd like to use it on

    1. Cross Posting Etiquette
    2. Are You Here To Learn: What Have You Tried?
    3. Your Best Resource to begin learning VBA: RECORD A MACRO . . . Then Study It!

  • #2
    The form in question had 200 + controls on it. It's been suggested, on another Excel / VBA Programming board that I had run into the upper limit for module size. I've be removing controls to seperate forms and all code works as planned.

    So keep in mind that there is a limit to module size in VBA.
    Regards,
    Barry

    My Favorite New Thing:
    Dynamic Named Ranges



    The alternative for
    "Press Any Key To Continue."

    and we all have one we'd like to use it on

    1. Cross Posting Etiquette
    2. Are You Here To Learn: What Have You Tried?
    3. Your Best Resource to begin learning VBA: RECORD A MACRO . . . Then Study It!

    Comment

    Working...
    X