469,333 Members | 4,550 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,333 developers. It's quick & easy.

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

Nov 1 '08 #1
3 1349
8,800 Expert 8TB
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.
Nov 1 '08 #2
Thank U It Works, However I Want To Customarise The Error Message In Case Of Duplicate Bill Entry Kindly Help Me

Nov 5 '08 #3
3,532 Expert 2GB
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


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

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Error(DataErr As Integer, Response As Integer)
  2. Dim Message As String
  3.  If DataErr = 3022 Then 'Duplicate Bill entered
  4.   Message = "You Have Attemped to Enter A Duplicate Bill"
  5.   Response = MsgBox(Message, vbExclamation, "Duplicate Bill")
  6.   Response = acDataErrContinue
  7.   Me.Undo
  8. End If
  9. 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)>
Nov 5 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Andrew Arace | last post: by
4 posts views Thread by alexandre.brisebois | last post: by
1 post views Thread by bandkindy | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by haryvincent176 | last post: by
reply views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.