astarbyfar
Registered User.
- Local time
- Today, 04:46
- Joined
- Apr 27, 2003
- Messages
- 93
Im having a problem with the following code:
Private Sub PSM_Code_BeforeUpdate(Cancel As Integer)
Dim PSM As String
PSM = Me.PSM_Code.Value
'Check Part table for duplicate PSM Codes
If DCount("PSM_Code", "Part", "[PSM_Code]=" & "'" & PSM & "'") > 0 Then
'Message box warning of duplication
If MsgBox("Warning PSM Code " & PSM & " has already been entered.", vbOKOnly, "Duplicate Primary keys") = vbOK Then Cancel = True
End If
End Sub
Everything works and it picks up the duplicate. However when I re-enter a PSM code that isnt a duplicate it still gives me a message. Anyone got any ideas?
Private Sub PSM_Code_BeforeUpdate(Cancel As Integer)
Dim PSM As String
PSM = Me.PSM_Code.Value
'Check Part table for duplicate PSM Codes
If DCount("PSM_Code", "Part", "[PSM_Code]=" & "'" & PSM & "'") > 0 Then
'Message box warning of duplication
If MsgBox("Warning PSM Code " & PSM & " has already been entered.", vbOKOnly, "Duplicate Primary keys") = vbOK Then Cancel = True
End If
End Sub
Everything works and it picks up the duplicate. However when I re-enter a PSM code that isnt a duplicate it still gives me a message. Anyone got any ideas?