access fields in a table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sashijagan
    New Member
    • Nov 2008
    • 4

    access fields in a table

    I want to avoid duplicate data in my table by comparing the value of 3 fields.
    Ex : I have a table with three fields 1.party name 2 .invoice No 3.invoice date
    I want to avoid duplicate entry of invoice by comparing the above three fields.How I have to do.
    kindly help me

    v.jagannathan
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    You need to create a Composite, Primary Key/Index in order to insure that the combination of these 3 values are unique. In Table Design View:
    1. Select the 3 Fields, namely [Party Name], [Invoice No], and [Invoice Date].
    2. Right Click within the selection.
    3. Select Primary Key.

    Comment

    • sashijagan
      New Member
      • Nov 2008
      • 4

      #3
      Thank U It Works, However I Want To Customarise The Error Message In Case Of Duplicate Bill Entry Kindly Help Me

      V.jagannathan

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        You don't say what you want to do in case an attempt is made to enter a duplicate bill, so we'll use the line

        Me.Undo

        to undo what you've entered. If this is not your intent, simply omit this line from the code below:

        Code:
        Private Sub Form_Error(DataErr As Integer, Response As Integer)
        Dim Message As String
         If DataErr = 3022 Then 'Duplicate Bill entered
          Message = "You Have Attemped to Enter A Duplicate Bill"
          Response = MsgBox(Message, vbExclamation, "Duplicate Bill")
          Response = acDataErrContinue
          Me.Undo
        End If
        End Sub
        I'll also post this in your other thread on this subject. BTW, posting a new thread with this new question was the correct thing to do!

        Welcome to Bytes!

        Linq ;0)>

        Comment

        Working...