Report with a moveable text box

C

chris.nebinger

Okay, gang, here's my problem. I have a 200 page report to print out.
Each page is one specific item. Each item is a group header, with any
number of detail lines. So far, so good.

Now, I want to list a letter on the right side of the page to make it
very easy to flip through the report. Again, easy enough.

I want that letter to move down the page according to which letter, A
being at the top, Z being at the bottom.

I can do this inside the group header:


Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As
Integer)
Dim intTop As Integer
Dim intStart As Integer
intTop = Asc(Left(AttributeName, 1)) - 65
txtLetter.Top = Int(GroupHeader0.Height / 26 * (intTop))
End Sub


However, I am limited to the header. I want it to go through the whole
page. I tried using the page_report event, but I think I can only draw
lines..... Any ideas?
 
M

Marshall Barton

Okay, gang, here's my problem. I have a 200 page report to print out.
Each page is one specific item. Each item is a group header, with any
number of detail lines. So far, so good.

Now, I want to list a letter on the right side of the page to make it
very easy to flip through the report. Again, easy enough.

I want that letter to move down the page according to which letter, A
being at the top, Z being at the bottom.

I can do this inside the group header:


Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As
Integer)
Dim intTop As Integer
Dim intStart As Integer
intTop = Asc(Left(AttributeName, 1)) - 65
txtLetter.Top = Int(GroupHeader0.Height / 26 * (intTop))
End Sub


However, I am limited to the header. I want it to go through the whole
page. I tried using the page_report event, but I think I can only draw
lines..... Any ideas?


A couple of ways to get that effect. The easiest is, as you
suspected, to use the Page event. Set the report properties
Me.CurrentX and Me.CurrentY to the appropriate position on
the page and use Me.Print to print the letter.
 
F

fredg

Okay, gang, here's my problem. I have a 200 page report to print out.
Each page is one specific item. Each item is a group header, with any
number of detail lines. So far, so good.

Now, I want to list a letter on the right side of the page to make it
very easy to flip through the report. Again, easy enough.

I want that letter to move down the page according to which letter, A
being at the top, Z being at the bottom.

I can do this inside the group header:

Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As
Integer)
Dim intTop As Integer
Dim intStart As Integer
intTop = Asc(Left(AttributeName, 1)) - 65
txtLetter.Top = Int(GroupHeader0.Height / 26 * (intTop))
End Sub

However, I am limited to the header. I want it to go through the whole
page. I tried using the page_report event, but I think I can only draw
lines..... Any ideas?

You're not limited to lines using the Page event.
Adapted from VBA help example on the Page event:

Private Sub Report_Page()
Dim rpt As Report
Dim strMessage As String
Dim intHorSize As Integer, intVerSize As Integer
Static intPlacement As Integer
Static intX As Integer

Set rpt = Me
strMessage = Chr(65)
strMessage = Chr(65 + intX)

With rpt
'Set scale to pixels, and set FontName and
'FontSize properties.
.ScaleMode = 3
.FontName = "Courier"
.fontsize = 24
End With

' Horizontal width.
intHorSize = rpt.TextWidth(strMessage)
' Vertical height.
intVerSize = rpt.TextHeight(strMessage)
' Calculate location of text to be displayed.
rpt.CurrentX = rpt.ScaleWidth - intHorSize
rpt.CurrentY = 0 + intPlacement
' Print text on Report object.
rpt.Print strMessage
intX = intX + 1
' Start at A again for next 26 pages
If intX = 26 Then intX = 0
intPlacement = intPlacement + intVerSize
' Start at top of report when restarting at A
If intX = 0 Then intPlacement = 0

End Sub

If you use a smaller (or larger) font size, you will need to adjust
the vertical spacing accordingly.

The above starts printing at the top of the report, at the extreme
right side, and works down to the bottom of the page.
 

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