Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
KeyDown event on form Horatio J. Bilge, Jr. Excel Discussion (Misc queries) 0 October 26th 07 03:30 PM
Keypress nest Garry Jones Excel Programming 4 October 21st 03 02:56 PM
keypress Garry Jones Excel Programming 2 October 17th 03 09:47 AM
keydown event jim c. Excel Programming 1 October 10th 03 03:16 AM
KeyPress Event Conrado Capistrano Excel Programming 4 September 25th 03 05:27 AM


All times are GMT +1. The time now is 10:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"