From: Greg (codepug on
In a continuous form, I capture the keydown event to determine if the
Del key was pressed. I have a routine that processes the Delete as I
see fit.
However, if the user is in a control in the Form Header, I do not want
the del Key
processed.

How do I determine if the forms header has control ? This may solve my
problem.

Thanks
From: Marshall Barton on
Greg (codepug(a)gmail.com) wrote:

>In a continuous form, I capture the keydown event to determine if the
>Del key was pressed. I have a routine that processes the Delete as I
>see fit.
>However, if the user is in a control in the Form Header, I do not want
>the del Key
>processed.
>
>How do I determine if the forms header has control ? This may solve my
>problem.


I answered this in mpa queries yesterday.

Try checking the active control's Section property.
0 - Detail
1 - Header
2 - Footer

If you did not follow that, here's a skeletal example:
If Me.ActiveControl.Section = 1 Then
'in detail section, do somerhing
Else
' not in detail, do nothing
End If

--
Marsh
From: Stuart McCall on
<codepug(a)gmail.com> wrote in message
news:656e44b6-ee48-4bc8-8789-d92b32299b32(a)z10g2000yqb.googlegroups.com...
> In a continuous form, I capture the keydown event to determine if the
> Del key was pressed. I have a routine that processes the Delete as I
> see fit.
> However, if the user is in a control in the Form Header, I do not want
> the del Key
> processed.
>
> How do I determine if the forms header has control ? This may solve my
> problem.
>
> Thanks
>

Select Case Me.ActiveControl.Section
Case acHeader
'Don't process Delete
Case acDetail, acFooter
'Process Delete
End Select


From: Stuart McCall on
Also, don't forget to discard the Delete keypress with:

KeyCode = 0


From: Greg (codepug on
Thanks Stuart

I tried your code, however I'm trapping the following error that
occurs when in the form detail area.

2472 / The espression you entered required the control to be in the
active window / Form_KeyDown

Any ideas?

Private Sub Form_KeyDown(KeyCode As Integer, SHIFT As Integer)
'*************************************************************
'UTIL: Key interpreter. Restricts keys.
On Error GoTo Err_Handler
If KeyCode = 35 Or KeyCode = 36 Then
' Shut off the Home & End key in this module.
KeyCode = 0
End If
If KeyCode = 46 Then 'Del key was pressed
Select Case Me.ActiveControl.Section 'Process a record delete
Case acHeader, acFooter
'In the form header, process Del key normally
Case acDetail
Call DelRecord
End Select
End If
KeyCtrl = "PgUpDnON"
Call KbdSecurity(KeyCtrl, KeyCode, SHIFT)
Exit_Point:
Exit Sub
Err_Handler:
MsgBox Err.Number & " / " & Err.DESCRIPTION & " / " &
"Form_KeyDown"
Resume Exit_Point
End Sub


Private Sub DelRecord()
If MsgBox("You are about to DELETE 1 record selected by pointer."
& vbCr & vbLf & vbCr & vbLf & _
"If you click Yes, you won't be able to undo this Delete
operation" & vbCr & vbLf & _
"Are you sure you want to Delete this record ?",
vbQuestion + vbYesNo, _
"Delete Record ?") = vbYes Then
Me.T_SICK_DELFLAG = True
Me.DELDATE = Now()
Me.Requery
Call GoToBottom
End If
End Sub