Determine if a Form has Header/Footer

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everybody,

How can I examine if a form has Header/Footer with code ?

Greatly appreciate any help.
Thank you.
 
Try the following function:

Function HeaderExists(WhichForm As Form) As Boolean
On Error Resume Next

HeaderExists = WhichForm.Section(acHeader).Visible
If Err.Number = 2462 Then
Err.Clear
Else
Err.Raise Err.Number, "HeaderExists", Err.Description
End If

End Function

Inside a form, you'd call this as

If HeaderExists(Me) Then
MsgBox "This form has a visible header"
Else
MsgBox "This form does not have a visible header"
End If

From a module, you can use HeaderExists(Forms!NameOfForm)

The form must be open for the function to work.
 
Using VBA function - the following code is not fully tested, but it should
give you the idea.

Public Function HasHeader(frmAny As Form) As Boolean
Dim TfAny As Boolean

On Error GoTo HasHeader_Error
TfAny = frmAny.Section(acHeader).Visible
HasHeader = True

Exit Function

HasHeader_Error:
HasHeader = False 'Error 2462
End Function

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Back
Top