I
Ivan
Hello,
I have two tables like Orders and Order_Detail with primary key orderId on
the first and primary key pair (orderId, itemId) on the second table.
Parallely I have a main form for Orders and a subform for Order_Details,
where both forms are connected with orderId key. Although I have both tables
linked on MS SQL Server and there exist a foreign key relationship, with the
intention to avoid the standard SQL Server message for violation of foreign
key constraint I check alone if the itemId is double for the same orderId in
my BeforreUpdate event code of the input combo box of the itemId field and
in such case I demand the undo. The problem is that I get the "No current
record" error and I don't know how to avoid it?
My code:
Private Sub itemid_BeforeUpdate(Cancel As Integer)
If DCount("[itemId]", "Order_Details", "[itemid] = '" & Me.itemId & "' AND
[orderId] = " & Me.orderId) > 0 Then
MsgBox "There is a double itemId!", vbOKOnly, "Notice"
Me.Undo
Else
' some code
Cancel = False
End If
End Sub
Any help?
Ivan
I have two tables like Orders and Order_Detail with primary key orderId on
the first and primary key pair (orderId, itemId) on the second table.
Parallely I have a main form for Orders and a subform for Order_Details,
where both forms are connected with orderId key. Although I have both tables
linked on MS SQL Server and there exist a foreign key relationship, with the
intention to avoid the standard SQL Server message for violation of foreign
key constraint I check alone if the itemId is double for the same orderId in
my BeforreUpdate event code of the input combo box of the itemId field and
in such case I demand the undo. The problem is that I get the "No current
record" error and I don't know how to avoid it?
My code:
Private Sub itemid_BeforeUpdate(Cancel As Integer)
If DCount("[itemId]", "Order_Details", "[itemid] = '" & Me.itemId & "' AND
[orderId] = " & Me.orderId) > 0 Then
MsgBox "There is a double itemId!", vbOKOnly, "Notice"
Me.Undo
Else
' some code
Cancel = False
End If
End Sub
Any help?
Ivan