Tables("出入库明细").Filter = Filter
'此前余额
Dim dr As DataRow
Dim mr As Row = Tables("出入库明细").Rows(0) (问题可能出在此行,因为空表中没有此行存在)
dr = DataTables("出入库明细").Find("[_SortKey] < " & mr("_SortKey") & " And [仓库] = '" & mr("仓库") & "' And [产品ID] = '" & mr("产品ID") & "' ", "[_SortKey] Desc")
If dr IsNot Nothing Then
e.Form.Controls("NumericComboBox1").value = dr("库存")
Else
e.Form.Controls("NumericComboBox1").value = Nothing
End If