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!

How to reduce space between report lines in code

Status
Not open for further replies.

marcello62

Technical User
Jun 19, 2006
42
NL
Hello,

I design a report using the following code:

'begin

Dim txtNew As Access.TextBox
Dim labNew As Access.Label
Dim lngTop As Long
Dim lngLeft As Long
Dim lblCol As Long
Dim rpt As Report
Dim strSql As String
Dim db As Database
Dim rs As Recordset
Dim i As Integer
Dim prevColwidth As Long

Set db = CurrentDb()

lngLeft = 0
lngTop = 0

DoCmd.OpenReport "rptOverzicht", acViewDesign

Set rpt = Reports![rptOverzicht]

strSql = "SELECT * FROM tmpOverzicht; "

Set rs = db.OpenRecordset(strSql)
rpt.RecordSource = strSql

prevColwidth = 0
lblCol = 0

For i = 0 To rs.Fields.Count - 1

Set labNew = CreateReportControl(rpt.Name, acLabel, acPageHeader, , rs.Fields(i).Name, lblCol, , , lngTop)
labNew.SizeToFit
lblCol = lblCol + 600 + labNew.Width
Next

For i = 0 To rs.Fields.Count - 1
Set txtNew = CreateReportControl(rpt.Name, acTextBox, acDetail, , , lngLeft + 15 + prevColwidth, lngTop)
txtNew.SizeToFit
txtNew.TextAlign = 1
txtNew.ControlSource = rs(i).Name
prevColwidth = prevColwidth + txtNew.Width
Next

DoCmd.OpenReport "rptOverzicht", acViewPreview

'end

It works, but the space between the lines in the report is too big, I want to reduce it so that I can print more lines on one page. Does anyone know how to do this?

Thanks.
 
Hello,

I tried your code and ran it in a empty DB.
What I found is that by default, REPORT DETAIL is at 3cm.

So it might be the reason why you have to much space between each line.

My suggestion is that
A) You modify the report DETAIL height by code to the minimum.

or you can also build a static report.

Hope it helps you a little

SG
 
I was able using
Code:
rpt.Section(acDetail).Height = 100
to reduce significantly the space between the lines but this is assuming that you left the report on default sizes witch I now doupt.

It might help. Let me know if it does.





SG
 
Reduce the font size too?


Ian Mayor (UK)
Program Error
Programming is 1% coding, 50% error checking and 49% sweat as your application bombs out in front of the client.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top