Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
problem while input numbers to a field
Hi guys, i am new to this forum and new to Access 07 and VBA
i need to a custom msg if someone enters a dublicate number in a
field in the form but i cant make it to work with the code bellow i
wont allow you to enter any new record.
The form is Employee Table, Field N I N
Private Sub NIN_BeforeUpdate(Cancel As Integer)
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.[N I N]
stLinkCriteria = "[NIN]=" & "'" & SID & "'"
'Check Employee Table table for duplicate
If DCount("NIN", "Employee Table", stLinkCriteria) > 0 Then
'Undo duplicate entry
'Message box warning of duplication
MsgBox "Warning NIN Number " _
& SID & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", _
vbInformation, "Duplicate Information"
'Go to record of original record
'Me.Bookmark = rsc.Bookmark
Set rsc = Nothing
0 · ·