改成
If Tables("采购主表").current.DataRow.RowState <> DataRowState.Unchanged Then
Dim Result As DialogResult
Result = MessageBox.Show("是否保存", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
'MessageBox.Show("不错,说明你已经认真学习了.","提示")
If Tables("采购主表").current("供应商") = Nothing Then
msgbox("请先输入供应商")
Return ""
End If
For Each r As Row In Tables("采购主表.采购明细表").rows
If r("名称") = Nothing Then
msgbox("请先输入名称")
Return ""
End If
Next
With Tables("采购主表")
If .Current IsNot Nothing Then
.Current.Save()
End If
End With
DataTables("采购明细表").Save()
ElseIf result = DialogResult.No
Tables("采购主表").Current.Delete()
Else
Return
End If
End If
Forms("入库单").Close()
Forms("主窗口").Open()