I have tblRegister
Column1: BillNr (123456)
Column2: Date (17.11.11)
How to restrict enterin same bill number on current year?
Column1: BillNr (123456)
Column2: Date (01.01.11-31.12.11) Restrict
Column1: BillNr (123456)
Column2: Date (01.01.12-......) Allow
I us this vba code for duplicat value
Private Sub BillNr_BeforeUpdate(Cancel As Integer)
'*********************************
'Code sample courtesy of srfreeman
'*********************************
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.BillNr.Value
stLinkCriteria = "[BillNr]=" & "'" & SID & "'"
'Check tblRegistertable for duplicate BillNr
If DCount("BillNr", "tblRegister", _
stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "BillNr " _
& SID & " its registrent on database." _
& vbCr & vbCr & "Klik to se registred bill.", _
vbInformation, "Warning"
'Go to record of original BillNr
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
End Sub
Thanks.
Column1: BillNr (123456)
Column2: Date (17.11.11)
How to restrict enterin same bill number on current year?
Column1: BillNr (123456)
Column2: Date (01.01.11-31.12.11) Restrict
Column1: BillNr (123456)
Column2: Date (01.01.12-......) Allow
I us this vba code for duplicat value
Private Sub BillNr_BeforeUpdate(Cancel As Integer)
'*********************************
'Code sample courtesy of srfreeman
'*********************************
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.BillNr.Value
stLinkCriteria = "[BillNr]=" & "'" & SID & "'"
'Check tblRegistertable for duplicate BillNr
If DCount("BillNr", "tblRegister", _
stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "BillNr " _
& SID & " its registrent on database." _
& vbCr & vbCr & "Klik to se registred bill.", _
vbInformation, "Warning"
'Go to record of original BillNr
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
End Sub
Thanks.