dbTalk Databases Forums  

How do I determine if the FormHeader has focus in a continuous form ?

comp.databases.ms-access comp.databases.ms-access


Discuss How do I determine if the FormHeader has focus in a continuous form ? in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Greg (codepug@gmail.com)
 
Posts: n/a

Default How do I determine if the FormHeader has focus in a continuous form ? - 07-28-2010 , 08:20 AM






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

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: How do I determine if the FormHeader has focus in a continuousform ? - 07-28-2010 , 10:35 AM






Greg (codepug (AT) gmail (DOT) com) wrote:

Quote:
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
I created a function
Private Function Junk()
MsgBox Me.ActiveControl.Name & " " & Me(s).Tag
End Function

Then I selected the controls for the header and selected the property
sheet and set the tag to "Header". Then set the GotFocus event to
=Junk()

IOW, I suppose one could check the control's tag. This is an option,
others may have a better method.

Reply With Quote
  #3  
Old   
Marshall Barton
 
Posts: n/a

Default Re: How do I determine if the FormHeader has focus in a continuous form ? - 07-28-2010 , 12:22 PM



Greg (codepug (AT) gmail (DOT) com) wrote:

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

Reply With Quote
  #4  
Old   
Stuart McCall
 
Posts: n/a

Default Re: How do I determine if the FormHeader has focus in a continuous form ? - 07-28-2010 , 12:28 PM



<codepug (AT) gmail (DOT) com> wrote

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

Reply With Quote
  #5  
Old   
Stuart McCall
 
Posts: n/a

Default Re: How do I determine if the FormHeader has focus in a continuous form ? - 07-28-2010 , 12:32 PM



Also, don't forget to discard the Delete keypress with:

KeyCode = 0

Reply With Quote
  #6  
Old   
Greg (codepug@gmail.com)
 
Posts: n/a

Default Re: How do I determine if the FormHeader has focus in a continuousform ? - 07-30-2010 , 08:16 AM



I discovered that the error occurs when the Record Selector in the
continuous form has focus.
I am able to accomplish what I was looking to do, however I have to
manage it by trapping the error
code & processing from there. I wonder if there is a way to identify
when the record selector has focus?

Thanks
Greg

Reply With Quote
  #7  
Old   
Jon Lewis
 
Posts: n/a

Default Re: How do I determine if the FormHeader has focus in a continuous form ? - 07-30-2010 , 09:34 AM



I haven't tested this extensively but it does seem to work.

Every Access Form has a Windows Handle which is a unique runtime identifier
for the Form's Window. These identifers are used for Windows API functions.
The Access property that exposes this for a Form is Hwnd as in Me.Hwnd. But
in fact, this property is actually the handle for the Record Selectors of
the Form. Although Access controls are not windows in their own right
(unlike VB controls) they do acquire a Windows Handle when they have focus.
So have a look at the code below which uses the Windows API function
GetFocus to get the Handle of whatever has the focus and adapt for your
needs:

Option Compare Database
Option Explicit

Private Declare Function GetFocus Lib "user32" () As Long 'in Declarations
section of the Form Class Module

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 46 Then
Dim lFocus As Long
lFocus = GetFocus
If lFocus = Me.Hwnd Then
MsgBox "Record Selector has focus"
Else
MsgBox "Focus is elsewhere"
End If
End If
End Sub

Jon


<codepug (AT) gmail (DOT) com> wrote

Quote:
I discovered that the error occurs when the Record Selector in the
continuous form has focus.
I am able to accomplish what I was looking to do, however I have to
manage it by trapping the error
code & processing from there. I wonder if there is a way to identify
when the record selector has focus?

Thanks
Greg

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.