Restricting Duplication

A

AN

Hi
I've the following code for restricting the duplication of OrdRef. It's
working fine, but i have one more requirement.The OrdRef format is
"PO/1700-R.0/2004". The "R.0" stands for the revision of the order.

BeforeUpdate Event:
------------------
Dim OrdNo As Integer
OrdNo = DCount("[OrdRef]", "OrdTBL", "[OrdRef] = '" &
[Forms]![Ordentry]![Text29] & "'")

If OrdNo <> 0 Then
MsgBox "DUPLICATION !"
Cancel = True
End If

Table name = OrdTBL
Field in table = OrdRef
Form Name = Ordentry
Control on form = Text29

What i am looking for is the following
When I add a new record with the same number(1700) it should warn me that i
am duplicating, however it should allow me to modify the existing number as
PO/1700-R.1/2004 if required.

In other words when a new record is add the system should check the number
in between the two slashes if the number (eg:1700) exist then it should not
allow, else continue...

Please help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top