Checking if Record Selector has the Focus

M

Michael

Is there a better way to check if the Record Selector has the focus?
Here is how I would do it:

if "Me.ActiveControl.Name" gives the error 2474 the no controls has the
focus, so it must be the Record Selector.

I need the Record Selector but want to prevent copy/paste from it. (I would
then EmptyClipBoard)

Any suggestion will be appreciated,

Thanks,

Michael
 
A

Allen Browne

Before you run your copy/paste code, you could make sure the 'record' itself
is selected with:
RunCommand acCmdSelectRecord
 
M

Michael

I need the Record Selector to be able to delete records and to select records
for calculation.

But I want to Prevent or disable copy/paste from Record Selector.

So I thought to detect if the Record Selector had the focus so then the
Clipboard would be emptied.


But you got me thingking, I saw the path I was taking was wrong. I found the
answer to preventing Paste form Record Selector : Detecting Ctrl-V key stroke
and preventing ShortcutMenu in the Record Selector.

Here is my code if it might interest somebody, or if somebody might suggest
better way:

'Detect ctrl-V combination and disable Paste
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If Shift = acCtrlMask And KeyCode = vbKeyV Then
MsgBox "Ctrl-V Error Message" 'If there is no MsgBox then Paste will
take effect!
End If
End Sub


'Bellow: Prevent ShortcutMenu in Record Selector and enable ShortcutMenu
elsewhere
Private Sub Form_Open(Cancel As Integer)
Enable_ShorcutMenu_In_Controls
End Sub

Private Sub Enable_ShorcutMenu_In_Controls()
Dim ctl As Control

If Me.ShortcutMenu = False Then
For Each ctl In Me.Controls
ctl.OnMouseDown = "=ShortcutMenu_True()"
Next
End If
End Sub

Private Function ShortcutMenu_True()
Me.ShortcutMenu = True
End Function


Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single,
Y As Single)
If X <= 255 Then
'MsgBox "No Right-Click"
Me.ShortcutMenu = False
Else
Me.ShortcutMenu = True
End If
End Sub

Private Sub FormHeader_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me.ShortcutMenu = True
End Sub

Private Sub Detail_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me.ShortcutMenu = True
End Sub

Private Sub FormFooter_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me.ShortcutMenu = True
End Sub



Thanks

Michael
 

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