ListBox MultiSelect and Ctrl-A

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

I can only get Ctrl-A to select all items if I open the
form acDialog. Unfortunately this is causing other
problems. Can anyone get the Ctrl-A to work without
acDialog?

thanks,
(e-mail address removed)
 
Hi Brian,

Try this: set the KeyPreview property of the form to True. The create a
KeyDown event for the listbox:

Private Sub List2_KeyDown(KeyCode As Integer, Shift As Integer)
Dim fctl As Boolean
Dim lngZ As Long
fctl = Shift And acCtrlMask
If fctl And KeyCode = vbKeyA Then
For lngZ = 0 To Me.List2.ListCount
Me.List2.Selected(lngZ) = True
Next lngZ
KeyCode = 0
End If
End Sub
 
Sandra,
This works but it takes too much time when working with
thousands of records. I can now open the form acDialog
without the other problems with the menus / commandbars.

Thanks,
Brian
-----Original Message-----
Hi Brian,

Try this: set the KeyPreview property of the form to True. The create a
KeyDown event for the listbox:

Private Sub List2_KeyDown(KeyCode As Integer, Shift As Integer)
Dim fctl As Boolean
Dim lngZ As Long
fctl = Shift And acCtrlMask
If fctl And KeyCode = vbKeyA Then
For lngZ = 0 To Me.List2.ListCount
Me.List2.Selected(lngZ) = True
Next lngZ
KeyCode = 0
End If
End Sub


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

I can only get Ctrl-A to select all items if I open the
form acDialog. Unfortunately this is causing other
problems. Can anyone get the Ctrl-A to work without
acDialog?

thanks,
(e-mail address removed)

.
 
Back
Top