Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[Access 2000] Accessing header properties using VBA?

Status
Not open for further replies.

jmc39

Programmer
Jun 19, 2003
4
GB
Can anybody tell me how I can access the header and footer properties of a form in Access 2000 using VBA?

The most I have found out is how the access the detail using forms("form1").section(0)....

Thanks for the help
 

forms("form1").section(acHeader)....

forms("form1").section(acFooter)....

Your 0 in the brackets is the equivalent of acDetail.
(ie if you debug.print acDetail in the immediate window, it displays 0.)

John
 
Thanks for the response but when I try, for example
"Forms("test").Section(acHeader).BackColor" I get the error "The section number you entered is invalid".

I've seen that I may have to add a header before it is actually present in form? is this true? does anybody know how to do this?

Thanks again
 
This is probably becuase there is no header, as you guessed.
To add one, go into form design, go to the view menu and click on Form Header/Footer. This will add one.

John
 
:(

Sorry, I forgot to mention this in the original post. Everything I am doing needs to be done through VBA. So what I need to be able to do is to add the header (or footer) using VBA.
 
This code snippet will do it.



Dim lngTemp As Long

Code:
DoCmd.OpenForm "frmData", acDesign
On Error Resume Next
lngTemp = Forms("frmData").Section(acHeader).Height
' err 2462 = Section not found
If Err.Number <> 2462 Then
    ' item already exists
    MsgBox &quot;Form has header/footer&quot;
Else
    DoCmd.RunCommand acCmdFormHdrFtr
End If

John
 
jrbarnett, your a life saver, thanks

James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top