Ozgrid Excel Help & Best Practices Forums

Excel Training / Excel Dashboards Reports

Results 1 to 2 of 2

Thread: [Solved] KeyDown vs KeyPress Events

  1. #1
    Join Date
    22nd January 2004
    Colorado Springs
    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
    '' Step 1 : Holding the shift key indicates user wants to change the order of
    ' 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?

    Excel Video Tutorials / Excel Dashboards Reports

  2. #2
    Join Date
    22nd January 2004
    Colorado Springs
    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.

    Excel Video Tutorials / Excel Dashboards Reports

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Keydown Invokes Click Event
    By Wadester in forum Excel and/or Access Help
    Replies: 2
    Last Post: June 11th, 2008, 23:15
  2. Replies: 2
    Last Post: April 14th, 2004, 00:27
  3. [Solved] VBA: Run events by clicking a cell
    By fliss in forum Excel General
    Replies: 9
    Last Post: August 29th, 2003, 05:55
  4. VBA: keypress
    By shuki in forum Excel General
    Replies: 2
    Last Post: August 8th, 2003, 04:51
  5. [Solved] VBA: Declaring Events and how they fire
    By brewguy99 in forum Excel General
    Replies: 4
    Last Post: June 14th, 2003, 00:13


Posting Permissions

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