How can I put dictionary-style page headers in an Access report?

D

DataGear

In word you can use StyleRef to create dictionary-style page headers, but I
can seem to find a way to do the same in an Access Report.
 
M

Marshall Barton

DataGear said:
In word you can use StyleRef to create dictionary-style page headers, but I
can seem to find a way to do the same in an Access Report.


Not sure what you want in the header, but if it's the first
and last detail on the page, then it gets pretty tricky.

It's easy to get the first detail in the page header by just
refering to the desired field. The same is true for getting
the last detail in the page footer.

If that's not sufficient, post back with more details.
 
D

DataGear

Thanks for the feedback - and sorry I didn't provide more detail on the
initial submittal.

I have a three column report that lists a series of name and address
information. I would like to have dictionary style heading the will help
people find the name they are looking for faster.

I have tried what you said below in the past and it works, but I would like
to have both the first and last detail record values in the header. Is there
any way to get them both in the header???
 
M

Marshall Barton

DataGear said:
I have a three column report that lists a series of name and address
information. I would like to have dictionary style heading the will help
people find the name they are looking for faster.

I have tried what you said below in the past and it works, but I would like
to have both the first and last detail record values in the header. Is there
any way to get them both in the header???


Like I said, it's tricky. First add a text box to the Page
Header or Footer that uses the Pages property
(=Page & " of " & Pages will do fine). This forces the
report to be processed twice, slow but necessary to get
values from the end to appear at the beginning.

Declare a module level array to use to save the last item on
each page:

Dim strLastItems(500) As String

Now, add code to the Page Footer section Format event to
save the last item on the page:

strLastItems(Me.Page) = Me.LName

Then add code to the Page Header Format event to retrieve
the saved value and put it in the page header sictionary
style text box:

Me.thetextbox = Me.LName & " - " & strLastItems(Me.Page)
 
D

DataGear

Thanks for the help, this works great!!!

Marshall Barton said:
Like I said, it's tricky. First add a text box to the Page
Header or Footer that uses the Pages property
(=Page & " of " & Pages will do fine). This forces the
report to be processed twice, slow but necessary to get
values from the end to appear at the beginning.

Declare a module level array to use to save the last item on
each page:

Dim strLastItems(500) As String

Now, add code to the Page Footer section Format event to
save the last item on the page:

strLastItems(Me.Page) = Me.LName

Then add code to the Page Header Format event to retrieve
the saved value and put it in the page header sictionary
style text box:

Me.thetextbox = Me.LName & " - " & strLastItems(Me.Page)
 
J

Jemsson

Hello
Thanks for this code.
But I tested it and work only when the Text Box option "Not Can Grew".
It give wrong result when The Text Box on Detail option format choose YES to
" Can Grew"

Do you have any ide to fix it such as make compare with every page that view
or something like that, to let it work when text box can grew ?

Thank you
 
Q

qumranandy

My dictionary is formatted as one big table with three columns - the Greek
words at left in Greek alphabetical order, the biblical Hebrew phrase
including the material which the Greek word helps translate at the right, and
in the middle is the Greek phrase that translates the Hebrew if the
translation is not exact. How can I get the dictionary headers at the top?
(First Greek word and last Greek word on the page).
Fincke
 
F

fredg

My dictionary is formatted as one big table with three columns - the Greek
words at left in Greek alphabetical order, the biblical Hebrew phrase
including the material which the Greek word helps translate at the right, and
in the middle is the Greek phrase that translates the Hebrew if the
translation is not exact. How can I get the dictionary headers at the top?
(First Greek word and last Greek word on the page).
Fincke

Let's assume the name of the field is "GreekWord".

The PageHeader has access to the first detail record.
So to show the first record on each page all you need do is to place
the [GreekWord] control in the header.
Whatever the first record on the page is will be shown in the Header.

To show the last Greek Word in the Page Header requires a little work.
Add a new table to the database.
ID Field (AutoNumber No Duplicates)
FinalGreekWord (Text)
Name the table 'tblPageHeader'

For the first record in the table enter a space (or anything)
in the FinalGreekWord field.
Continue adding records (by adding a space in the FinalGreekWord field
for as many pages as you expect the report to have,
incrementing the ID field by 1 each record.
So if you expect 20 pages, make 20+ records.
(This can be done using code, but that would be another post.)

In the Report, add a control to compute [Pages].
If you don't already have one
= [Page] & " of " & [Pages]
will do.

Then add a control in the Page Header where you
wish to display the final Greek word on the page:
=DLookUp("[FinalGreekWord]","tblPageHeader","[ID] = " & [Page])


The Page Footer has access to the last Detail record.
Code the Report's PageFooter Format event:

CurrentDb.Execute "Update tblPageHeader Set FinalGreekWord = " &
Chr(34) & [GreekWord] & Chr(34) & "Where [ID] = " & [Page],
dbFailOnError

Note: The above should be all on one line, or split using the Space
Underscore combination.

Run the report.
The [Pages] control forces the report to be formatted twice.
On the first pass, the table is updated after each page
with the final Greek word on that page.
Then the report is displayed and the DLookUp in the Page Header
control reads the corresponding page name from the table.

Worked fine for me the last time I ran it.
 
Q

qumranandy

Thanks, Fred.
Now I know what "It's Greekl to me" means. Here's what Word help says about
"Dictionary Stle Headers":
Format the names in the document by using a paragraph (paragraph style: A
combination of character- and paragraph-formatting characteristics that are
named and stored as a set. You can select a paragraph and use the style to
apply all of the formatting characteristics to the paragraph at one time.) or
character style (character style: A combination of any of the character
formatting options identified by a style name.). Insert two STYLEREF fields
in the document header."
I have no idea what "detail record", "field code", "Report" mean. So let's
try at the beginning. How do I reformat my document from table format to
paragraph format, so I can use the Word help solution? Or, let's just stick
with your advice and use the first word for the page-header. How do I assign
the contents of column 1 to a "field"? And then what does "The Pageheader
has access to the first detail record" mean?



fredg said:
My dictionary is formatted as one big table with three columns - the Greek
words at left in Greek alphabetical order, the biblical Hebrew phrase
including the material which the Greek word helps translate at the right, and
in the middle is the Greek phrase that translates the Hebrew if the
translation is not exact. How can I get the dictionary headers at the top?
(First Greek word and last Greek word on the page).
Fincke

Let's assume the name of the field is "GreekWord".

The PageHeader has access to the first detail record.
So to show the first record on each page all you need do is to place
the [GreekWord] control in the header.
Whatever the first record on the page is will be shown in the Header.

To show the last Greek Word in the Page Header requires a little work.
Add a new table to the database.
ID Field (AutoNumber No Duplicates)
FinalGreekWord (Text)
Name the table 'tblPageHeader'

For the first record in the table enter a space (or anything)
in the FinalGreekWord field.
Continue adding records (by adding a space in the FinalGreekWord field
for as many pages as you expect the report to have,
incrementing the ID field by 1 each record.
So if you expect 20 pages, make 20+ records.
(This can be done using code, but that would be another post.)

In the Report, add a control to compute [Pages].
If you don't already have one
= [Page] & " of " & [Pages]
will do.

Then add a control in the Page Header where you
wish to display the final Greek word on the page:
=DLookUp("[FinalGreekWord]","tblPageHeader","[ID] = " & [Page])


The Page Footer has access to the last Detail record.
Code the Report's PageFooter Format event:

CurrentDb.Execute "Update tblPageHeader Set FinalGreekWord = " &
Chr(34) & [GreekWord] & Chr(34) & "Where [ID] = " & [Page],
dbFailOnError

Note: The above should be all on one line, or split using the Space
Underscore combination.

Run the report.
The [Pages] control forces the report to be formatted twice.
On the first pass, the table is updated after each page
with the final Greek word on that page.
Then the report is displayed and the DLookUp in the Page Header
control reads the corresponding page name from the table.

Worked fine for me the last time I ran it.
 
F

fredg

Thanks, Fred.
Now I know what "It's Greekl to me" means. Here's what Word help says about
"Dictionary Stle Headers":
Format the names in the document by using a paragraph (paragraph style: A
combination of character- and paragraph-formatting characteristics that are
named and stored as a set. You can select a paragraph and use the style to
apply all of the formatting characteristics to the paragraph at one time.) or
character style (character style: A combination of any of the character
formatting options identified by a style name.). Insert two STYLEREF fields
in the document header."
I have no idea what "detail record", "field code", "Report" mean. So let's
try at the beginning. How do I reformat my document from table format to
paragraph format, so I can use the Word help solution? Or, let's just stick
with your advice and use the first word for the page-header. How do I assign
the contents of column 1 to a "field"? And then what does "The Pageheader
has access to the first detail record" mean?

fredg said:
My dictionary is formatted as one big table with three columns - the Greek
words at left in Greek alphabetical order, the biblical Hebrew phrase
including the material which the Greek word helps translate at the right, and
in the middle is the Greek phrase that translates the Hebrew if the
translation is not exact. How can I get the dictionary headers at the top?
(First Greek word and last Greek word on the page).
Fincke

:

In word you can use StyleRef to create dictionary-style page headers, but I
can seem to find a way to do the same in an Access Report.

Let's assume the name of the field is "GreekWord".

The PageHeader has access to the first detail record.
So to show the first record on each page all you need do is to place
the [GreekWord] control in the header.
Whatever the first record on the page is will be shown in the Header.

To show the last Greek Word in the Page Header requires a little work.
Add a new table to the database.
ID Field (AutoNumber No Duplicates)
FinalGreekWord (Text)
Name the table 'tblPageHeader'

For the first record in the table enter a space (or anything)
in the FinalGreekWord field.
Continue adding records (by adding a space in the FinalGreekWord field
for as many pages as you expect the report to have,
incrementing the ID field by 1 each record.
So if you expect 20 pages, make 20+ records.
(This can be done using code, but that would be another post.)

In the Report, add a control to compute [Pages].
If you don't already have one
= [Page] & " of " & [Pages]
will do.

Then add a control in the Page Header where you
wish to display the final Greek word on the page:
=DLookUp("[FinalGreekWord]","tblPageHeader","[ID] = " & [Page])

The Page Footer has access to the last Detail record.
Code the Report's PageFooter Format event:

CurrentDb.Execute "Update tblPageHeader Set FinalGreekWord = " &
Chr(34) & [GreekWord] & Chr(34) & "Where [ID] = " & [Page],
dbFailOnError

Note: The above should be all on one line, or split using the Space
Underscore combination.

Run the report.
The [Pages] control forces the report to be formatted twice.
On the first pass, the table is updated after each page
with the final Greek word on that page.
Then the report is displayed and the DLookUp in the Page Header
control reads the corresponding page name from the table.

Worked fine for me the last time I ran it.

I'm confused.

You apparently are attempting to use Microsoft Word.
Please ignore my reply to your previous post.

You posted your question to the wrong newsgroup.
The access in this groups name refers to Microsoft Access, a database
program.

Please repost your original question to the correct newsgroup for the
Word program you are using. I would suggest you include your Windows
and Office version number in the message.
 

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