Hello,
I have a table with 2 fields set as primary key. One is the ProjectID and the second is CostAccountID, when both are combined they will become a unique key.
I want to replace the default warning message of access to prevent the duplicate entry. To do this, i used dcount function but i seem to have problem in referencing the primary key.
I would be willing to accept suggestions too.
Thank you and kind regards,
namu
I have a table with 2 fields set as primary key. One is the ProjectID and the second is CostAccountID, when both are combined they will become a unique key.
I want to replace the default warning message of access to prevent the duplicate entry. To do this, i used dcount function but i seem to have problem in referencing the primary key.
I would be willing to accept suggestions too.
Code:
Private Sub CostAccountID_BeforeUpdate(Cancel As Integer)
If DCount("CostAccountId", "tblRates1", "ProjectID = " & Me.ProjectID) > 0 Then
MsgBox "Duplicate Record"
Me.Undo
End If
End Sub
namu