Data Duplicatiion - Please help

A

ARN

I've a table which has the following fields

Date
Emp_ID
MediCal_allowance
Ticket-Fare
House_Allowace
Daily_Allowance

I've the form having the above mentioned fields

What I'm looking for is the following
I want to avoid duplication that means, in a year , an
employee entitled for the medical,ticket and
House_Allowace is once . if the user try to enter the
above allowance again in the same year the program
should
give a message that the employee has already been paid,
and duplication should not allow, on the other had the
system should allow the user to enter the daily
allowance
for same employee( that means no restrictions in daily
allowance)

someone gave me the following method
====================================

If Not IsNull(DCount("*", "table", "Emp_ID=" & Me.txtEmpID _
& " And Year([Date])=" & Year(Me.txtDate) _
& " And House_Allowance Is Not Null") Then
MsgBox "Duplicate House Allowance"
Cancel = True

I've used this method, but now it is not allowing me any
record to add. as soon I finish entering it doesnot allow
me to save. I need the system to allow once, only the
duplication to be avoided. Please help
ARN
 
B

Bill Taylor

Try this code:

If NZ(DCount("*", "table", "Emp_ID=" & Me.txtEmpID _
& " And Year([Date])=" & Year(Me.txtDate) _
& " And House_Allowance Is Not Null"), 0) <> 0 Then
MsgBox "Duplicate House Allowance"
Cancel = True
 

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