Count of Selected Controls

Shaimaa T

Registered User.
Local time
Today, 05:43
Joined
Aug 11, 2014
Messages
40
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

Code:
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
 

Users who are viewing this thread

Back
Top Bottom