以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助] 遍历所有行后执行代码  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=91965)

--  作者:zcgmxf
--  发布时间:2016/10/23 9:40:00
--  [求助] 遍历所有行后执行代码

老师 ,我有一一类疫苗出库表,一列 确认下级退回 ,我想打印前判断所有行 确认下级退回 = true 后打印,否则只要有一行 确认下级退回 = false 退出打印。用for each 语句每遍历一行就要执行一次。学艺不精,不知如何编写代码,请指教。谢谢!

 

If Tables("一类疫苗出库单").current IsNot Nothing AndAlso Tables("一类疫苗出库单.一类疫苗出库表").current IsNot Nothing Then
    For Each dr As Row In Tables("一类疫苗出库表").Rows
        If dr("确认下级退回") = False Then
            MessageBox.Show("不能打印下级退回冲单,选择打印单据错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            Exit For
         Else
            Dim tm As String  = ProjectPath & "Attachments\\打印一类疫苗退回冲单.doc" \'指定模板文件
            Dim fl As String = ProjectPath & "Reports\\打印一类疫苗退回冲单.doc" \'指定目标文件
            Dim wrt As New WordReport(Tables("一类疫苗出库单"),tm,fl) \'定义一个WordReport
            wrt.Build() \'逐行生成报表
            wrt.print
            wrt.quit
        End If
    Next
Else
    MessageBox.Show("没有明细,无法打印!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
End If

[此贴子已经被作者于2016/10/23 11:23:01编辑过]

--  作者:zcgmxf
--  发布时间:2016/10/23 11:48:00
--  
各位大神,是不是这个问题又很简单啊。图片点击可在新窗口打开查看
--  作者:狐狸爸爸
--  发布时间:2016/10/23 16:50:00
--  

If Tables("一类疫苗出库单").current IsNot Nothing AndAlso Tables("一类疫苗出库单.一类疫苗出库表").current IsNot Nothing Then
    For Each dr As Row In Tables("一类疫苗出库表").Rows
        If dr("确认下级退回") = False Then
            MessageBox.Show("不能打印下级退回冲单,选择打印单据错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            Return
        End If
    Next
Else
    MessageBox.Show("没有明细,无法打印!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
End If

Dim tm As String  = ProjectPath & "Attachments\\打印一类疫苗退回冲单.doc" \'指定模板文件
Dim fl As String = ProjectPath & "Reports\\打印一类疫苗退回冲单.doc" \'指定目标文件
Dim wrt As New WordReport(Tables("一类疫苗出库单"),tm,fl) \'定义一个WordReport
wrt.Build() \'逐行生成报表
wrt.print
wrt.quit

[此贴子已经被作者于2016/10/23 16:50:37编辑过]