PDA

View Full Version : Count of Selected Controls



Shaimaa T
08-18-2014, 03:27 AM
Hi all,


I have a form consisting of textboxes and I open it in datasheet view.


I want to be able to ctrl+v something if I am selecting only one control(one textbox).


But if several texboxes are selected , or the whole record ...then I want to pop up a user-friendly message and disable pasting.


I am thinking of something like



Dim Pasted As Boolean
Dim ctrl As Control


Private Sub Form_BeforeInsert(Cancel As Integer)
If (ctrl.ItemsSelected.Count > 1) Then <--- this seems to be wrong /missing
Cancel = Pasted
If (Cancel = True) Then
MsgBox "Please paste one field at a time"
End If
End If


Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)


Pasted = KeyCode = vbKeyV And Shift = acCtrlMask


End Sub

ranman256
08-18-2014, 05:34 AM
I dont understand how you can 'select' text boxes. You are either in 1 text box or not. You cant select many.
clarify pls.

Shaimaa T
08-18-2014, 06:11 AM
Clicking at the leftmost part to select a complete record
12130
Selecting a textbox and clicking Shift then selecting another 2
12131
Or Selecting a single textbox
12132