problem while input numbers to a field - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

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

islandboyislandboy Posts: 2Member


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


thanks.



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
Me.Undo
'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
'rsc.FindFirst stLinkCriteria
'Me.Bookmark = rsc.Bookmark

End If

Set rsc = Nothing

End Sub
Sign In or Register to comment.