报错说“报表宽度大于打印纸宽度”,你帮我看看是怎么回事,我不会弄了,谢谢^_^  Private Sub DataReport_Initialize()
Dim leftpos As Long 'leftpos为存放控件left属性的变量
Dim reportwidth As Long 'reportwidth为存放Datareport总宽度的变量
 If frmrpt.lst_selected.ListCount <> 0 Then
'Call frmrpt.fieldwidth(frmrpt.lst_selected) '设置字段宽度
 
Const wordwidth As Integer = 201 '五号字的宽度为201缇
For i = 0 To frmrpt.lst_selected.ListCount - 1
Select Case frmrpt.lst_selected.List(i)
Case "学号"
frmrpt.lst_selected.ItemData(i) = wordwidth * 5
Case "姓名"
frmrpt.lst_selected.ItemData(i) = wordwidth * 4
Case "性别"
frmrpt.lst_selected.ItemData(i) = wordwidth * 2
 ......
 
 End Select
Next i'求总宽度
For i = 0 To frmrpt.lst_selected.ListCount - 1
reportwidth = reportwidth + frmrpt.lst_selected.ItemData(i)
Next
With Dtreport
'设置数据源,页边距,标题,横向分割线,section1、2区第一条竖分割线
.LeftMargin = 1440
.RightMargin = 1440
.TopMargin = 1440
.BottomMargin = 144
.reportwidth = Printer.Width - 2880 - 20
Set adoCon = New ADODB.Connection
 adoCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & strAppPath & ""
  adoCon.Open
 Set .DataSource = rs
Dtreport.Sections.Item("section4").Controls.Item("Label41").Caption = frmrpt.txt_caption
Dtreport.Sections("section4").Controls.Item("Label41").Width = reportwidth
......
End With'为section1,2区设置数据
leftpos = 0
For i = 0 To frmrpt.lst_selected.ListCount - 1
Me.Sections("section2").Controls("Label2" & (i + 1)).Caption = frmrpt.lst_selected.List(i)
Me.Sections("section2").Controls.Item("Label2" & (i + 1)).Caption = frmrpt.lst_selected.List(i)
Me.Sections("section2").Controls.Item("Label2" & (i + 1)).Width = frmrpt.lst_selected.ItemData(i)
Me.Sections("section2").Controls.Item("Label2" & (i + 1)).Left = leftpos
Me.Sections("section1").Controls.Item("Text1" & (i + 1)).DataField = rs.Fields.Item(i).Name
 ........i = frmrpt.lst_selected.ListCount
While i < (Me.Sections("section1").Controls.Count - 19)
'10 为section1区域的非text控件的控件总数
i = i + 1
Me.Sections("section1").Controls.Item("Text1" & i).DataField = rs.Fields.Item(0).Name
Me.Sections("section1").Controls.Item("Text1" & i).Visible = False
.......
Wend
 End If
 Me.PrintReport True
End Sub

解决方案 »

  1.   

    就是报表宽度超出了打印纸张的宽度嘛!!即(假设rpt为DataReport控件):
    rpt.LeftMargin + rpt.ReportWidth + rpt.RightMargin > Printer.Width
      

  2.   

    這個應該是設計DataReport的時候拖的過寬了
      

  3.   

    不是让不打印的Visible属性设为 false就可以吗
      

  4.   

    你的DataRePort的边缘一定贴主控件的边缘
    还有就是有两个属性你要设置成0 忘了是什么了 反正就是 左右边距(翻译)