Sink Access report section events such as Format, Print, and Retre

E

Erik Eckhardt

I'm using Access 2002 ADP to do some data-driven report formatting. Instead
of putting code in each report to modify itself at run-time, I thought I'd
just make some class modules that knew how to respond to all report events
and take action as the events occur.

Sinking the Open, Close, Activate, etc. events on the Report object itself
works fine. But that's not enough, I need section events. However, when I
declare a variable of type Section, the only events available are *form*
run-time events such as Click, DblClick, MouseDown, and so on.

Report sections that have events are named things like Detail,
PageHeaderSection, ReportHeader, but the names can change, which led me to
this suspicion: Maybe the way Access handles these section events is by
inheriting the generic Report class, because not all reports or forms have
the same sections. For example, you can declare new form events all you like
on a form--it's a class module. But you can't sink those events if the
WithEvents variable you use is declared as type Access.Form. Instead, you
have to declare it as type Form_MyForm, or whatever the name of your form is.
That sucks because if you want to declare a special event on many different
forms, you have to use a separate variable for each form.

So I looked to see if I could declare my variable as Report_MyReport, but
alas, no reports show up in the intellisense dropdown as valid object
declaration types like forms do. But this could explain why neither the
Report object nor the Section object expose the events I want to sink.

I really really wanted to be able to do this, it would be SO powerful and
use so little code and be SO maintainable.

Can someone please help?

Erik
 
S

Stephen Lebans

Sample code for how to sink Report Section events is in the PrintLinesClass
project on my site I think.
Here's a snip from the start of the class:

' Module : clsPLSection
' Description:
' Procedures : InitSection(curSection As Section, lngLineBorderWidthDefault
As Long)
' Get BottomMargin()
' Get SectionIndex()
' Let SectionIndex(NewValue As Integer)
' Get SelectControlsMode()
' Let SelectControlsMode(fSelectCtls As Boolean)
' Get TopMargin()
' Get zSection()
' Draw(pSection As ClsSectionProperties)
' DrawBorder(pSectionProperties As ClsSectionProperties)
' DrawVerticaLines(pSectionProperties As ClsSectionProperties)
' mSection_Print(pintCancel As Integer, pIntCount As Integer)
' mSectionDetail_Format(pintCancel As Integer, pintFormatCount
As Integer)

' Modified :
' 01/22/02 S Cleaned with Total Visual CodeTools 2000
'
' --------------------------------------------------
Option Compare Database
Option Explicit
Private Const mcstrModule As String = "clsPLSection"
' The sections here require a different interface than
' the standard _SectionInReport. The PageHeader & PageFooter
' have their own object interface: _PageHdrFtrInReport
' If you try to enter these Type declarations in another module
' you'll need to do it like this:
' Access.[_SectionInReport] AND Access.[_PageHdrFtrInReport]
' since the underscore character is an illegal char for
' prfexing a Type declaration.


Private WithEvents mSection As Access.[_SectionInReport]
Private WithEvents mSectionPageHeader As Access.[_PageHdrFtrInReport]
Private WithEvents mSectionPageFooter As Access.[_PageHdrFtrInReport]
Private mobjGenSection As Object

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
E

Erik Eckhardt

I did confirm that sinking section events using these type declarations
works. I thank you! (And boy how messy it is...)

Where did you ever learn these type names? I find them in no documentation
and certainly not in the object browser. These special classes starting with
underscores... did you examine Access type libraries using developer tools?

Erik

--
Elbisrever isn't.


Stephen Lebans said:
Sample code for how to sink Report Section events is in the PrintLinesClass
project on my site I think.
Here's a snip from the start of the class:

' Module : clsPLSection
' Description:
' Procedures : InitSection(curSection As Section, lngLineBorderWidthDefault
As Long)
' Get BottomMargin()
' Get SectionIndex()
' Let SectionIndex(NewValue As Integer)
' Get SelectControlsMode()
' Let SelectControlsMode(fSelectCtls As Boolean)
' Get TopMargin()
' Get zSection()
' Draw(pSection As ClsSectionProperties)
' DrawBorder(pSectionProperties As ClsSectionProperties)
' DrawVerticaLines(pSectionProperties As ClsSectionProperties)
' mSection_Print(pintCancel As Integer, pIntCount As Integer)
' mSectionDetail_Format(pintCancel As Integer, pintFormatCount
As Integer)

' Modified :
' 01/22/02 S Cleaned with Total Visual CodeTools 2000
'
' --------------------------------------------------
Option Compare Database
Option Explicit
Private Const mcstrModule As String = "clsPLSection"
' The sections here require a different interface than
' the standard _SectionInReport. The PageHeader & PageFooter
' have their own object interface: _PageHdrFtrInReport
' If you try to enter these Type declarations in another module
' you'll need to do it like this:
' Access.[_SectionInReport] AND Access.[_PageHdrFtrInReport]
' since the underscore character is an illegal char for
' prfexing a Type declaration.


Private WithEvents mSection As Access.[_SectionInReport]
Private WithEvents mSectionPageHeader As Access.[_PageHdrFtrInReport]
Private WithEvents mSectionPageFooter As Access.[_PageHdrFtrInReport]
Private mobjGenSection As Object

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Erik Eckhardt said:
I'm using Access 2002 ADP to do some data-driven report formatting.
Instead
of putting code in each report to modify itself at run-time, I thought I'd
just make some class modules that knew how to respond to all report events
and take action as the events occur.

Sinking the Open, Close, Activate, etc. events on the Report object itself
works fine. But that's not enough, I need section events. However, when I
declare a variable of type Section, the only events available are *form*
run-time events such as Click, DblClick, MouseDown, and so on.

Report sections that have events are named things like Detail,
PageHeaderSection, ReportHeader, but the names can change, which led me to
this suspicion: Maybe the way Access handles these section events is by
inheriting the generic Report class, because not all reports or forms have
the same sections. For example, you can declare new form events all you
like
on a form--it's a class module. But you can't sink those events if the
WithEvents variable you use is declared as type Access.Form. Instead, you
have to declare it as type Form_MyForm, or whatever the name of your form
is.
That sucks because if you want to declare a special event on many
different
forms, you have to use a separate variable for each form.

So I looked to see if I could declare my variable as Report_MyReport, but
alas, no reports show up in the intellisense dropdown as valid object
declaration types like forms do. But this could explain why neither the
Report object nor the Section object expose the events I want to sink.

I really really wanted to be able to do this, it would be SO powerful and
use so little code and be SO maintainable.

Can someone please help?

Erik
 
S

Stephen Lebans

Open up your object Browser window. Right click in anywhere in the window
and select "Show Hidden Members" from the popup menu.

The Type lib has these interfaces marked as hidden so they do not show in
the default Object Browser view of the TypeLib. I always use the Visual
Studio's Ole View app to directly examine any TypeLib I am interested in.
You never know what you might find!<grin>

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Erik Eckhardt said:
I did confirm that sinking section events using these type declarations
works. I thank you! (And boy how messy it is...)

Where did you ever learn these type names? I find them in no documentation
and certainly not in the object browser. These special classes starting
with
underscores... did you examine Access type libraries using developer
tools?

Erik

--
Elbisrever isn't.


Stephen Lebans said:
Sample code for how to sink Report Section events is in the
PrintLinesClass
project on my site I think.
Here's a snip from the start of the class:

' Module : clsPLSection
' Description:
' Procedures : InitSection(curSection As Section,
lngLineBorderWidthDefault
As Long)
' Get BottomMargin()
' Get SectionIndex()
' Let SectionIndex(NewValue As Integer)
' Get SelectControlsMode()
' Let SelectControlsMode(fSelectCtls As Boolean)
' Get TopMargin()
' Get zSection()
' Draw(pSection As ClsSectionProperties)
' DrawBorder(pSectionProperties As ClsSectionProperties)
' DrawVerticaLines(pSectionProperties As
ClsSectionProperties)
' mSection_Print(pintCancel As Integer, pIntCount As
Integer)
' mSectionDetail_Format(pintCancel As Integer,
pintFormatCount
As Integer)

' Modified :
' 01/22/02 S Cleaned with Total Visual CodeTools 2000
'
' --------------------------------------------------
Option Compare Database
Option Explicit
Private Const mcstrModule As String = "clsPLSection"
' The sections here require a different interface than
' the standard _SectionInReport. The PageHeader & PageFooter
' have their own object interface: _PageHdrFtrInReport
' If you try to enter these Type declarations in another module
' you'll need to do it like this:
' Access.[_SectionInReport] AND Access.[_PageHdrFtrInReport]
' since the underscore character is an illegal char for
' prfexing a Type declaration.


Private WithEvents mSection As Access.[_SectionInReport]
Private WithEvents mSectionPageHeader As Access.[_PageHdrFtrInReport]
Private WithEvents mSectionPageFooter As Access.[_PageHdrFtrInReport]
Private mobjGenSection As Object

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Erik Eckhardt said:
I'm using Access 2002 ADP to do some data-driven report formatting.
Instead
of putting code in each report to modify itself at run-time, I thought
I'd
just make some class modules that knew how to respond to all report
events
and take action as the events occur.

Sinking the Open, Close, Activate, etc. events on the Report object
itself
works fine. But that's not enough, I need section events. However, when
I
declare a variable of type Section, the only events available are
*form*
run-time events such as Click, DblClick, MouseDown, and so on.

Report sections that have events are named things like Detail,
PageHeaderSection, ReportHeader, but the names can change, which led me
to
this suspicion: Maybe the way Access handles these section events is by
inheriting the generic Report class, because not all reports or forms
have
the same sections. For example, you can declare new form events all you
like
on a form--it's a class module. But you can't sink those events if the
WithEvents variable you use is declared as type Access.Form. Instead,
you
have to declare it as type Form_MyForm, or whatever the name of your
form
is.
That sucks because if you want to declare a special event on many
different
forms, you have to use a separate variable for each form.

So I looked to see if I could declare my variable as Report_MyReport,
but
alas, no reports show up in the intellisense dropdown as valid object
declaration types like forms do. But this could explain why neither the
Report object nor the Section object expose the events I want to sink.

I really really wanted to be able to do this, it would be SO powerful
and
use so little code and be SO maintainable.

Can someone please help?

Erik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top