How to restrict duplicate record in particular conditions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Taloker
    New Member
    • Dec 2013
    • 2

    #1

    How to restrict duplicate record in particular conditions

    I have a form with three fields. Plate , KMS, and Status (Closed or AVL)

    EXAMPLE
    Record 1 when the Plate (1234) AND status= closed (DUPLICATE OK)

    Record 2 when the Plate (1234) AND status= closed (DUPLICATE OK)
    BUT
    Record 3 when the Plate (1234) AND status= AVL (NO DUPLICATE )

    can somebody help me
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3665

    #2
    Taloker,

    You would have to do this in VBA, probably on an AfterUpdate Event for the text boxes and combo boxes that hold your data. If it meets the necessary criteria, save the record, if not, cancel the update.

    Comment

    • jforbes
      Recognized Expert Top Contributor
      • Aug 2014
      • 1107

      #3
      You could also put the validation in the Form's BeforeUpdate Event and if your validation fails, set
      Code:
      Cancel=True
      to exit out of the event without saving the record.

      Reference: http://msdn.microsoft.com/en-us/libr...ffice.12).aspx

      Comment

      Working...