老师,我想实现两个表无法录入同一个编号,谢谢If e.DataCol.Name = "订单号" Then
Dim dr As DataRow
dr = e.DataTable.Find("订单号 = '" & e.NewValue & "'")
If dr IsNot Nothing Then
MessageBox.Show("此订单号已经存在!")
e.Cancel = True
End If
End If
这个是当前表的,但是涉及其他表的就没头绪了
[此贴子已经被作者于2024/6/14 12:26:51编辑过]
If e.DataCol.Name = "订单号" Then
Dim dr As DataRow
Dim dr1 As DataRow
dr = DataTables("表A").Find("订单号 = '" & e.NewValue & "'")
dr1 = DataTables("表B").Find("订单号 = '" & e.NewValue & "'")
If dr IsNot Nothing Or dr1 IsNot Nothing Then
MessageBox.Show("此订单号已经存在!")
e.Cancel = True
End If
End If
If e.DataCol.Name = "订单号" Then
Dim dr As DataRow
dr = e.DataTable.Find("订单号 = '" & e.NewValue & "'")
If dr Is Nothing Then
dr = DataTables("另一个表").Find("订单号 = '" & e.NewValue & "'")
End If
If dr IsNot Nothing Then
MessageBox.Show("此订单号已经存在!")
e.Cancel = True
End If
End If