Repeat Number Check Error

Johnthelleader

Registered User.
Local time
Today, 01:13
Joined
Nov 8, 2006
Messages
27
I have the following code in the before update criteria of a text box. The database is for recording invoices and it is a safety device to obviously stop the user entering duplicate invoice material. Yet when any invoice number is entered the warning still comes up eventhough the invoive number is unique. As a bonus, when it has detected there is a repeat number, would it be possible to be taken to that record?


Private Sub Invoice_Number_BeforeUpdate(Cancel As Integer)

Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset

Set rsc = Me.RecordsetClone

SID = Me.Invoice_Number.Value
stLinkCriteria = "Invoice_Number=" & "'" & SID & "'"

'Check StudentDetails table for duplicate StudentNumber
If DCount("Invoice_Number", "Invoices", stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning! This Invoice Number " _
& SID & " has already been entered." _
& vbCr, vbInformation _
, "Duplicate Information"


End If

Set rsc = Nothing
End Sub


Look forward to hearing some advices
 

Users who are viewing this thread

Back
Top Bottom