![]() |
KeyDown / KeyPress Events
I have a user form with 200+ controls. On various
listboxes I want the user to be able to use Ctrl + A to select all values and Ctrl + U to deselect all values. I also want the user to be able to use Shift + ArrowUp and Shift + ArrowDown to move the selections up and down in the list. One listbox contains the following code: ByVal Shift As Integer) ' Local Variables ' Step 1 : User selects 'ESC' key If KeyCode = 27 Then Unload Me ' Step 2 : Ctrl - A = select all ; Ctrl -U = deselect all If Shift = 2 Then If KeyCode = 65 Then Call SelectAllItems (Me.lboWorkStationNames, True) If KeyCode = 85 Then Call SelectAllItems (Me.lboWorkStationNames, False) End If End Sub Which works great. It does everything that I want it to. On another listbox the following code is present: Private Sub lboUpdWkStation_SelStations_KeyDown(ByVal KeyCode As MSForms.ReturnI nteger, ByVal Shift As Integer) ' ' Step 2 : Ctrl - A = select all ; Ctrl -U = deselect all If KeyCode = 65 Or KeyCode = 85 And Shift = 2 Then If KeyCode = 65 Then Call SelectAllItems (Me.lboUpdWkStation_SelStations, True) If KeyCode = 85 Then Call SelectAllItems (Me.lboUpdWkStation_SelStations, False) End If End Sub Both codes are identical in all aspects except for the name of the control. The problem that I get is during run time. The first listed form runs without issue. However, when attempting to perform the various functions on the second form nothing happens. I've tried putting a MsgBox line in to trap the error so that I can see where it stops but the event doesn't even get triggered. The VBE properties is locked upon opening of the workbook, and the problem above happens at this time. Now if I unlock the code It works just fine. Does anybody have any ideas. Short of making multiple forms to reduce the forms control count. Is there a limit on size that VBA can compile / run? Please let me know. my work e-mail = ( no attachements ) my home e-mail = Thanks |
KeyDown / KeyPress Events
Hi,
I think there is an undocumented limit of 64 kb size for modules in the VBE. Google around in this newsgroup and you will find postings about that. Regarding the size of userforms I assume they can be bigger - but 200 + controls sounds for me like really a lot ot of controls for one userform :-) I recommmend you to split them up into several forms and try this again. (With saying this I haven't tested your code, but I think this is probably the solution .) Hope this helps Ulrik Gustafsson "Barry Pettis" skrev i meddelandet ... I have a user form with 200+ controls. On various listboxes I want the user to be able to use Ctrl + A to select all values and Ctrl + U to deselect all values. I also want the user to be able to use Shift + ArrowUp and Shift + ArrowDown to move the selections up and down in the list. One listbox contains the following code: ByVal Shift As Integer) ' Local Variables ' Step 1 : User selects 'ESC' key If KeyCode = 27 Then Unload Me ' Step 2 : Ctrl - A = select all ; Ctrl -U = deselect all If Shift = 2 Then If KeyCode = 65 Then Call SelectAllItems (Me.lboWorkStationNames, True) If KeyCode = 85 Then Call SelectAllItems (Me.lboWorkStationNames, False) End If End Sub Which works great. It does everything that I want it to. On another listbox the following code is present: Private Sub lboUpdWkStation_SelStations_KeyDown(ByVal KeyCode As MSForms.ReturnI nteger, ByVal Shift As Integer) ' ' Step 2 : Ctrl - A = select all ; Ctrl -U = deselect all If KeyCode = 65 Or KeyCode = 85 And Shift = 2 Then If KeyCode = 65 Then Call SelectAllItems (Me.lboUpdWkStation_SelStations, True) If KeyCode = 85 Then Call SelectAllItems (Me.lboUpdWkStation_SelStations, False) End If End Sub Both codes are identical in all aspects except for the name of the control. The problem that I get is during run time. The first listed form runs without issue. However, when attempting to perform the various functions on the second form nothing happens. I've tried putting a MsgBox line in to trap the error so that I can see where it stops but the event doesn't even get triggered. The VBE properties is locked upon opening of the workbook, and the problem above happens at this time. Now if I unlock the code It works just fine. Does anybody have any ideas. Short of making multiple forms to reduce the forms control count. Is there a limit on size that VBA can compile / run? Please let me know. my work e-mail = ( no attachements ) my home e-mail = Thanks |
All times are GMT +1. The time now is 01:31 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com