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

Columns in subreport 1

Status
Not open for further replies.

gillianleec

Technical User
May 7, 2003
48
US
I have a report that prints for a location and has a subreport that prints the people associated with that location in columns. I have written code into the subreport that changes the fontsize depending on the recordcount in the subreport. I would also like to change the number of columns and column width in the subreport based on record count. I can do this with a printer object in the report design but am not allowed to use a printer object with a subreport. Does anybody have any suggestions on another way to handle this?

Here is my code for the subreport formatting:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim vardocname As Variant

vardocname = Me.txtdocname
Select Case Me.txtCountRec
Case Is > 4
With Me.Printer
.ItemsAcross = 2
.RowSpacing = 0
.ColumnSpacing = 0
.ItemSizeWidth = TextWidth(vardocname)
.ColumnSpacing = 0.2 * 1440
End With

Me.txtdocname.FontSize = 6
Me.txtdocname.Width = TextWidth(vardocname)

Case Is <= 4
With Me.Printer
.ItemSizeWidth = 5000
End With

Me.txtdocname.FontSize = 9
Me.txtdocname.Width = TextWidth(vardocname) + 175

End Select

End Sub

The error I get when I try to run this as a subreport is:

Printer object is not available on subforms and subreports.
 
There is a sample report that simulates columns without setting up columns in the report layout at You might be able to adapt the code to meet your needs.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
I need an original copy of this code again and cannot find mine. Is there any other place that it might be posted. This link no longer has it.

Thanks,
Gillian
 
Do you recall the mdb file name? It's been almost five years since I worked for invisible inc. and they recently removed all of my samples. Was the sample, the one with a phone list report that was set up with a single column but printed as if it was two columns?

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
yes-it was initally with a phone list. The records were set up so they were in two columns (across and then down)
 
Found it and posted it on my website
Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top