在某窗口动态增加了一个“生成销货单”按钮,全局事件代码如下,前面的数据都已经生成,最后打开窗口不成功。求大师指点
Select Case e.Sender.Name
Case "生成销货单"
Dim r1 As Row = Tables("销货订单").Current
Dim r2 As Row = Tables("销货单").AddNew
r2("客户") = r1("客户")
r2("销售员") = r1("销售员")
r2("关联销货订单号") = r1("订单编号")
r2("单据日期") = new Date.Today()
'r2("销售单号") = "XSCK20160801-001"
For Each x1 As Row In Tables("销货订单.销货订单明细").Rows
Dim x2 As Row = Tables("销货单.销货单明细").AddNew
x2("商品编号") = x1("商品编号")
x2("商品名称") = x1("商品名称")
x2("规格型号") = x1("规格型号")
x2("等级") = x1("等级")
x2("单位") = x1("单位")
x2("片重") = x1("片重")
x2("出库数量") = x1("数量")
x2("销售单价") = x1("单价")
x2("折扣率") = x1("折扣率")
x2("单据日期") = new Date.Today()
Next
Forms("销售单").Open()
End Select