Select All in Access 2002 List box

M

Mark Phillipson

Hi,

I have a list box that I wish to select all items when the user types
Ctrl+A.

I have tried using the Key Up event but can only seem to trap A not Ctrl+A

Any help would be appreciated....
 
A

Albert D. Kallal

Use the key down event. Setting KeyCode = 0 gulps the keypress into a black
hole

You can use the following code:

Dim iptr As Integer

If KeyCode = Asc("A") And (Shift = acCtrlMask) Then
KeyCode = 0
Beep
For iptr = 0 To Me.List2.ListCount
Me.List2.Selected(iptr) = True
Next iptr
End If

Note that listboxes are zero based. However, if you have the "show heading"
option set for the listbox, then you have to start itpr at 1, and NOT 0.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top