我用DATAREPORT 打印表格,datasource 是 ADODB.RECORDSET,
每次打印完成,再次更新ADODB.RECORDSET时,记录数会减少,如果不打印,刷新ADODB.RECORDSET,记录数不变,不知是什么原因?
请高手帮忙,谢谢

解决方案 »

  1.   

    后台数据库中没有减少,但用ADODB再更新时就减少了
      

  2.   

    打印部分 
      If MsgBox("是否打印药瓶签?", vbQuestion + vbOKCancel + vbDefaultButton2, Me.Caption) = vbCancel Then
        Exit Sub
      End If
      
      
      
      MRst_fz_ao_zybq.MoveFirst
      MRst_fz_ao_zybq_sl.MoveFirst
          Set rep_zybq.DataSource = MRst_fz_ao_zybq
        MRst_fz_ao_zybq_sl.Filter = ""
     Dim j, i, k, l, m As Integer
     For k = 1 To MRst_fz_ao_zybq_sl.RecordCount  MRst_fz_ao_zybq.Filter = "住院号" & " = '" & MRst_fz_ao_zybq_sl.Fields("pt_no").Value & "' and " & _
                "group_order" & " = '" & MRst_fz_ao_zybq_sl.Fields("group_order").Value & "'   "
      m = MRst_fz_ao_zybq.Fields("次数").Value
      For i = 1 To rep_zybq.Sections("section4").Controls.Count
        If rep_zybq.Sections("section4").Controls(i).Name = "Label22" Then
          rep_zybq.Sections("section4").Controls(i).Caption = Frm_Yzksfy.Text6.Text
        End If
        If rep_zybq.Sections("section4").Controls(i).Name = "Label23" Then
          rep_zybq.Sections("section4").Controls(i).Caption = MRst_fz_ao_zybq.Fields("住院号").Value
        End If
        If rep_zybq.Sections("section4").Controls(i).Name = "Label31" Then
          rep_zybq.Sections("section4").Controls(i).Caption = MRst_fz_ao_zybq.Fields("姓名").Value
        End If
        If rep_zybq.Sections("section4").Controls(i).Name = "Label33" Then
          rep_zybq.Sections("section4").Controls(i).Caption = MRst_fz_ao_zybq.Fields("床号").Value
        End If
      Next i
     For l = 1 To m
      For j = 1 To rep_zybq.Sections("section3").Controls.Count
        If rep_zybq.Sections("section3").Controls(j).Name = "Label9" Then
          rep_zybq.Sections("section3").Controls(j).Caption = l
        End If
        If rep_zybq.Sections("section3").Controls(j).Name = "Label10" Then
          rep_zybq.Sections("section3").Controls(j).Caption = m
        End If
        If rep_zybq.Sections("section3").Controls(j).Name = "Label12" Then
          rep_zybq.Sections("section3").Controls(j).Caption = MRst_fz_ao_zybq.Fields("group_order").Value
        End If
      Next j
        rep_zybq.PrintReport
     Next l
     MRst_fz_ao_zybq_sl.MoveNext
     
    Next k
      
     Set rep_zybq.DataSource = Nothing
     Unload rep_zybq数据刷新部分
            MRst_fz_ao_zybq.Open "" & _
            "SELECT fz_ao_recipe.PT_NAME as 姓名, group_order ,fz_ao_account.bed_id as 床号," & _
            " fz_ao_recipe.recipe_no as 处方号,dr_name AS 医生,supper_dr_id AS 麻醉批准人,fz_ao_recipe.pt_no AS 住院号,fz_ao_recipe.pt_name AS 患者姓名," & _
            " fz_ao_recipe.pt_sort_id AS 患者类别,fz_ao_recipe.dr_id AS 医生ID, dr_office_id AS 科室ID," & _
            " nr_id AS 护士ID,RECIPE_TYPE AS 处方类," & _
            " item_id AS 药品编码,item_name As 药品名称," & _
            " standard As 药品规格, unit As 单位," & _
            " retail As 单价, buy_price As 进价," & _
            " amount/frequence As 数量, retail*amount as 小计,frequence as 次数," & _
            " ITEM_TYPE  as 剂型," & _
            " if_PAY,form_date as 执行日期," & _
            " BATCH_CODE as 生产批号,item_rate" & _
            " FROM fz_ao_recipe LEFT OUTER JOIN " & _
            " fz_Pb_dr ON " & _
            " fz_ao_recipe.dr_id = fz_Pb_dr.dr_id  " & _
            " LEFT OUTER JOIN fz_ao_account ON " & _
            "  fz_ao_recipe.PT_NO = fz_ao_account.PT_NO " & _
            "  where (IF_PAY='" & McfhClass & "' or IF_PAY='3' or IF_PAY='4') and" & _
            "  pErform_OFFICE_ID='" & GPrformKS_ID & "' AND HIGH_RETAIL<>10 AND " & _
            "  form_date >= '" & mDateStatr & "' and  " & "  form_date <= '" & mDateEnd & "' and  " & _
            "  fz_ao_recipe.dr_advice_sort like '" & Myzlb & "%' AND " & _
            "  item_rate<>0 and  " & _
            "  LEFT(RECIPE_TYPE,1) = '1' and group_order<>0 AND " & lPt_noandRcipe & " " & _
            " ORDER BY fz_ao_recipe.PT_no,group_order,form_date,recipe_no", GCnHisdata, adOpenStatic, adLockOptimistic