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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to find whether a section exists in a form using vba

Status
Not open for further replies.

Ashank4vba

Programmer
Apr 29, 2005
115
IN
Hi,

I made a cursory search but could not find any recent posts in this topic.

I am trying to set the properties of a forms, section in VBA. How do I determine whether a form has a specific section? For example,

Code:
For ctr = 0 To 2 
If Not IsNull(frm.Section(ctr)) Then
frm.Section(ctr).BackColor = DarkBlue
End If
Next

ctr is an integer counter and DarkBlue is a constant value for color that I declared.

I try to run the above loop for detail, header and footer sections but I get an error saying "Section number you entered is invalid"

I tried using UBound(frm.section) to determine the number of existing sections in the form, but I get an error saying "argument not optional" since I guess Access is expecting me to provide an index for the section.

Plz help.
Thanks
 
Well, the form sections are acheader, acpageheader, acdetail, acpagefooter, acfooter. I don't think there's anything better than just triggering an error (2462, I think)...

[tt]on error resume next
frm.Section(ctr).BackColor = DarkBlue
if err.number<>0 then
' some other code
end if[/tt]

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top