数据库里存放多条记录,为什么打印的时候总是丢掉最后一个数据?大概代码如下:
For intI = 0 To 9
' If rstTemp2.EOF Then Exit For
data(1)=rsttemp2.fields("0")
rstTemp2.MoveNextNext intI
For intI = 0 To 9
' If rstTemp2.EOF Then Exit For
data(1)=rsttemp2.fields("0")
rstTemp2.MoveNextNext intI
解决方案 »
- 这个乘法问题在哪儿?
- 关于用API函数做校验程序的问题
- 文本操作问题,分析网页源码,取出需要的部分
- 在VB中如何用递归遍历多个数据表!
- 打开excel后,excel的菜单、工具栏都没有了,并且有个分栏,怎么解决?谢谢!!!
- 关于(canon sdk)顶着有分
- 关于mschart控件的问题!急用,在线等。。。
- 一个关于MSHFGRID 的简单问题!!
- 我只想点击DataGrid控件的列标头,却不想选中整个列,怎么办?---------在线等待
- VB中怎么根据前两个文本框的信息得出第三个文本框的值,第三个文本框做成下拉菜单
- 如何清除应用程序webbrowser控件
- cn.Execute "insert into user(username,passwd) values ('" & Trim(Text1.Text) & " ','" & Trim(Text2.Text) & "')"
data(1)=rsttemp2.fields("0")
rsttemp2.movenext
loop
while not rstTemp2.EOF
data(1)=rsttemp2.fields("0")
rstTemp2.MoveNext
wend
while not rsttemp2.eof
intI=intI+1
data(intI)=rsttemp2.fields("id")
rstTemp2.MoveNext
wend
For intI = 0 To 9
strName(0) = IIf(IsNull(rstTemp2.Fields!1), "", rstTemp2.Fields!1)
prnprint.CurrentX = LeftLimit + 40 - 0.5 * prnprint.TextWidth(strName(0))
prnprint.CurrentY = Top + 24 + 4 + 8 * intI - 0.5 * prnprint.TextHeight(strName(0))
prnprint.Print strName(0)
strName(1) = IIf(IsNull(rstTemp2.Fields!2), "", rstTemp2.Fields!2)
prnprint.CurrentX = LeftLimit + 80 + 25 - 0.5 * prnprint.TextWidth(strName(1))
prnprint.CurrentY = Top + 24 + 4 + 8 * intI - 0.5 * prnprint.TextHeight(strName(1))
prnprint.Print strName(1)
strMaterialName(2) = IIf(IsNull(rstTemp2.Fields!3), "", rstTemp2.Fields!3)
prnprint.CurrentX = LeftLimit + 80 + 50 + 25 - 0.5 * prnprint.TextWidth(strName(2))
prnprint.CurrentY = Top + 24 + 4 + 8 * intI - 0.5 * prnprint.TextHeight(strName(2))
prnprint.Print strName(2)
rstTemp2.MoveNext
Next intI
End If
intOldPageNumber = func(rstTemp2, 10)
func这是一个根据数据库的记录数进行分页的函数,这里是每一页存放10条记录。
这段代码是在窗体里写得,数据库没有关闭,上面的代码是再模块里写的,直接就从数据库里调数据。
看你的程序能看到10条记录,怎么看到14个?
大家建议你用while或do while,你没改。
你的用法for不好
用for应当写成
for I =0 to rstTemp2.count-1
这么用要先判断有记录
for I =0 to rstTemp2.count-1 ,这种写法我也写过,结果不仅缺最后一条记录还把所有数据都打印到一页上,我想要的是
每一页打10条记录,其余的记录接着往下一页打
Do Until .EOFloop