The code belongs in the report module, so you can take it out of the other
module. Pasting it into the report module should have worked, provided there
was not an existing PageFooterSection_Format procedure in that module.
The easiest way to create an event procedure is to select the object for
which you want to create an event procedure first. In this case, the object
is the report footer section. Another time, it might be another section, a
control such as a text box, or the report or form itself. If the Properties
window is not already visible, from the View menu select Properties. In the
Properties window, select the Event tab. Select the event you want - in this
case, On Format - and when it is selected a builder button will appear to
the right of the event property in the Properties window. Click that button,
and if prompted to select Expression Builder, Macro Builder or Code Builder,
select Code Builder. The VBA editor will automatically insert the procedure
declaration for you - the line beginning 'Private Sub ...' - and the 'End
Sub' line. You just have to add the code between those two lines, in this
case the "Me.Text0.Visible = (Me.Page <> 1)" line. Don't forget to change
'Text0' to the actual name of your text box.
When the VBA IDE highlights a line of code in red, that indicates that there
is a syntax error in the code. I tested the code before I posted it, but
there are various ways things can go wrong when copying code from a
newsgroup post to the VBA editor. Try compiling the code (from the Debug
menu, choose Compile <Your Project Name>). You should get an error message
that will indicate what the problem is.
--
Brendan Reynolds
Access MVP
StephanieH said:
You're right. It was in the page footer, not report footer. But I'm not
sure where to put your code. I tried going into Design view and selected
the
'code' icon. I pasted your code, but it shows the first line in red
"Private
Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)". I also tried inserting a module and pasting the code with the
same result.
I know I'm doing something wrong, but not sure what. Where should I put
the
code you've provided?
Brendan Reynolds said:
A report footer prints only once, at the end of the report. Perhaps you
meant a page footer? In a page footer, you could set the Visible property
of
the text box in the Format event procedure of the page footer ...
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
Me.Text0.Visible = (Me.Page <> 1)
End Sub
--
Brendan Reynolds
Access MVP
StephanieH said:
Is it possible to add a text box to a report footer, but have it
display
on
all pages except the first page?
Right now, my control source is =[Summary] but I'm thinking something
along
the lines of If Page = 1 then "", else =[Summary].
Sorry, I've more familiar with Excel than Access. Any help is
appreciated.
.