UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> IsSubformFocus    

A simple function to check if the focus is in a subform or the top level parent form. Useful for custom shortcut keys to navigate in/out of subform controls.


' IsSubformFocus
' http://www.utteraccess.com/wiki/index.php/IsSubformFocus
' Code courtesy of UtterAccess Wiki
' Licensed under Creative Commons License
' http://creativecommons.org/licenses/by-sa/3.0/
' You are free to use this code in any application,
' provided this notice is left unchanged.
' rev  date                          brief descripton
' 1.0  2011-04-27                    
Public Function IsSubformFocus() As Boolean
 On Error Resume Next
 Dim x As Object
 'get the control's form
 Set x = Screen.ActiveControl.Parent
 'check to make sure it's not a nested type control (e.g., Option control)
 If Not TypeOf x Is Access.Form Then Set x = x.Parent
 'attempt to get the form's parent, read the err number to determine if it has one
 Set x = x.Parent
 IsSubformFocus = Not CBool(Err.Number)

End Function

Creative Commons License
IsSubformFocus by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.

Edit Discussion
Custom Search

Thank you for your support!
This page has been accessed 3,554 times.  This page was last modified 01:11, 14 March 2012 by Jack Leach.   Disclaimers