数据库里存放多条记录,为什么打印的时候总是丢掉最后一个数据?大概代码如下:
For intI = 0 To 9
'   If rstTemp2.EOF Then Exit For
    data(1)=rsttemp2.fields("0")
 rstTemp2.MoveNextNext intI

解决方案 »

  1.   

    do while not rsttemp2.eof
        data(1)=rsttemp2.fields("0") 
        rsttemp2.movenext
    loop
      

  2.   

    用while循环试下
    while not rstTemp2.EOF 
        data(1)=rsttemp2.fields("0") 
        rstTemp2.MoveNext 
    wend
      

  3.   

    intI=0
    while not rsttemp2.eof 
        intI=intI+1
        data(intI)=rsttemp2.fields("id")
        rstTemp2.MoveNext 
    wend 
      

  4.   

    楼主说明:我用recordcount记录一下,应该是15条数据,但它直接显示14条,这怎么办
      

  5.   

    If Not rstTemp2.EOF Then
    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
      

  6.   

       rstTemp2.Open "select * from Data where [试验序号]='" & TestNumber & "'", ConnMe, adOpenKeyset, adLockOptimistic
      intOldPageNumber = func(rstTemp2, 10)
     func这是一个根据数据库的记录数进行分页的函数,这里是每一页存放10条记录。
    这段代码是在窗体里写得,数据库没有关闭,上面的代码是再模块里写的,直接就从数据库里调数据。            
      

  7.   

    Fields!字段名称是用汉字写的,临时改了一下,不是用这种写法:rsttemp2.fields!(0).
      

  8.   


    看你的程序能看到10条记录,怎么看到14个?
    大家建议你用while或do while,你没改。
    你的用法for不好
    用for应当写成
    for I =0 to rstTemp2.count-1
      

  9.   

    for I =0 to rstTemp2.count-1 
    这么用要先判断有记录
      

  10.   

    我用了while或do while,结果一样,还是缺最后一条记录;
    for I =0 to rstTemp2.count-1 ,这种写法我也写过,结果不仅缺最后一条记录还把所有数据都打印到一页上,我想要的是
    每一页打10条记录,其余的记录接着往下一页打
      

  11.   

    用DO UNTIL进行循环打印
    Do Until .EOFloop
      

  12.   

    把你用while改写的语句贴出来