我的报表是写代码做的,没用设计器。可是数据总是显示不上去呢?请教高手!帮我看看代码!

hanbd 2001-12-12 05:43:52
我的报表是写代码做的,没用设计器。可是数据总是显示不上去呢?请教高手!帮我看看代码!我一共有4个表里数据要选10个数据显示在报表里,以下是数据显示的一段,帮我看看从数据库里取数据有没有问题,有什么可能导致死机呢?或是坐标写的不对?
'***************************** 填数据*****************************************
If Not rstTemp.BOF Then
strMaterialName(0) = IIf(Not IsNull(rstTemp!材料说明), rstTemp!材料说明, "")
strMaterialName(1) = IIf(Not IsNull(rstTemp!筛孔类型), rstTemp!筛孔类型, "")
For i = 0 To 1
prnPrint.CurrentX = PaperLeftLimit + 87.5 * i + 12 - 0.5 * prnPrint.TextWidth(strMaterialName(i))
prnPrint.CurrentY = TopOfMain + 4 - 0.5 * prnPrint.TextHeight("细")
prnPrint.Print strMaterialName(i)
Next i
End If
If Not rstTemp.BOF Then
strMaterialName(0) = IIf(Not IsNull(rstTemp!混合料名称), rstTemp!混合料名称, "")
strMaterialName(1) = IIf(Not IsNull(rstTemp!级配类型), rstTemp!级配类型, "")
For i = 0 To 1
prnPrint.CurrentX = PaperLeftLimit + 87.5 * i + 12 - 0.5 * prnPrint.TextWidth(strMaterialName(i))
prnPrint.CurrentY = TopOfMain + 8 - 0.5 * prnPrint.TextHeight("细")
prnPrint.Print strMaterialName(i)
Next i
End If
'---------------------------------------------
rstTemp1.Open "Select 筛孔号,低通过百分率,高通过百分率 from TPHB5_Data1 where 试验序号='" & strTestNumber & "' order by 筛孔号", ConnMe, adOpenKeyset, adLockReadOnly
rstTemp2.Open "Select 筛孔号,总质量,材料名称 from TPHB5_Data2 where 材料名称='" & strMaterialName(i) & "'and 试验序号='" & strTestNumber & "' order by 筛孔号", ConnMe, adOpenKeyset, adLockReadOnly
rstTemp3.Open "Select 筛孔号,通过百分率,材料名称 from TPHB5_Data3 where 试验序号='" & strTestNumber & "' order by 筛孔号", ConnMe, adOpenKeyset, adLockReadOnly

For i = 1 To rstTemp2.RecordCount
prnPrint.CurrentX = PaperLeftLimit + 12 - 0.5 * prnPrint.TextWidth(strMaterialName(i))
prnPrint.CurrentY = TopOfMain + 3 * 8 + 4 + 12 * i - 0.5 * prnPrint.TextHeight("细")
prnPrint.Print strMaterialName(i)

strTemp = Trim("" & rstTemp2.Fields!总质量)
prnPrint.CurrentX = PaperLeftLimit + 12 + 16 - 0.5 * prnPrint.TextWidth(strTemp)
prnPrint.CurrentY = TopOfMain + 3 * 8 + 4 + 12 * i - 0.5 * prnPrint.TextHeight("细")
prnPrint.Print strTemp

For j = 1 To rstTemp3.RecordCount
strTemp = Trim("" & rstTemp2.Fields!分计筛余质量)
prnPrint.CurrentX = PaperLeftLimit + 48 + (j - 1) Mod 16 * 10 + -0.5 * prnPrint.TextWidth(strTemp)
prnPrint.CurrentY = TopOfMain + 3 * 8 + (i - 1) * 8 + 4 - 0.5 * prnPrint.TextHeight("细")
prnPrint.Print strTemp


prnPrint.FontSize = prnPrint.FontSize * 0.75
strTemp = Trim("" & rstTemp2.Fields!筛孔尺寸)
prnPrint.CurrentX = PaperLeftLimit + 48 + (j - 1) Mod 16 * 10 + -0.5 * prnPrint.TextWidth(strTemp)
prnPrint.CurrentY = TopOfMain + 20 - 0.5 * prnPrint.TextHeight("细")
prnPrint.Print strTemp
prnPrint.FontSize = prnPrint.FontSize / 0.75
strTemp = Trim("" & rstTemp2.Fields!低通过百分率)
prnPrint.CurrentX = PaperLeftLimit + 48 + (j - 1) Mod 16 * 10 + -0.5 * prnPrint.TextWidth(strTemp)
prnPrint.CurrentY = TopOfMain + HeightOfMain - 3 - 0.5 * prnPrint.TextHeight("细")
prnPrint.Print strTemp
prnPrint.FontSize = prnPrint.FontSize / 0.75
strTemp = Trim("" & rstTemp2.Fields!高通过百分率)
prnPrint.CurrentX = PaperLeftLimit + 48 + (j - 1) Mod 16 * 10 + -0.5 * prnPrint.TextWidth(strTemp)
prnPrint.CurrentY = TopOfMain + HeightOfMain - 7 - 0.5 * prnPrint.TextHeight("细")
prnPrint.Print strTemp
rstTemp2.MoveNext
Next j
Next i
...全文
117 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
apollo 2001-12-12
  • 打赏
  • 举报
回复
有关系的,文字的CurrentXY 是会受到影响的
hanbd 2001-12-12
  • 打赏
  • 举报
回复
我是想解决怎么把数据从数据库里取出来。显示在报表里呢?格式我已经画完了。
hanbd 2001-12-12
  • 打赏
  • 举报
回复
这个有影响吗?从什么地方可以看出来呢?
hanbd 2001-12-12
  • 打赏
  • 举报
回复
我想解决的是报表的格式我已经画好了,预揽出来了.可是怎么从数据库里把数据取出显示在里面呢
apollo 2001-12-12
  • 打赏
  • 举报
回复
你的printer对象用的是像素还是cm还是什么什么的
hanbd 2001-12-12
  • 打赏
  • 举报
回复
什么prnprint的什么单位?
apollo 2001-12-12
  • 打赏
  • 举报
回复
prnPrint的单位是什么?
hanbd 2001-12-12
  • 打赏
  • 举报
回复
我运行老是死机,可是调试时还是有值,但就是显示不上去呢?

807

社区成员

发帖
与我相关
我的任务
社区描述
VB 多媒体
社区管理员
  • 多媒体
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧