改成
DataTables("明细账").DataRows.Clear
Dim txt As WinForm.TextBox = e.Form.Controls("tb科目代码")
Dim dr2 As DataRow = DataTables("会计科目").find("科目代码 = '"& txt.text & "'")
If dr2 IsNot Nothing Then
Dim dr3 As DataRow = DataTables("明细账").addnew
dr3("日期") = #01/01/2008#
dr3("余额") = dr2("期初余额")
dr3("方向") = dr2("方向")
dr3("摘要") = "期初余额"
End If
For Each dr As DataRow In DataTables("凭证明细").Select("科目代码 = '"& txt.Text & "'")
Dim dr1 As DataRow = DataTables("明细账").AddNew()
dr1("日期") = dr("日期")
dr1("凭证ID") = dr("凭证ID")
dr1("摘要") = dr("摘要")
dr1("借方") = dr("借方金额")
dr1("贷方") = dr("贷方金额")
Next
[此贴子已经被作者于2019/1/6 20:52:13编辑过]