Hi everybody. I am having a very confusing problem trying to check for duplicate records in a table before posting employee time keeping information.
I am using a query to check our existing records in the employee time table when the 'Save Record' button is pressed. The query looks like this:
[tt]SELECT COUNT(*)
FROM "EMP_TIME.DBF" Emp_time
WHERE (Emp_time."date" = :cdate)
AND (prempl =
rempl)
AND (total_hours = :total_hours)
AND (job_type = :job_type)
AND (clinic = :clinic)[/tt]
As you can tell I'm trying to count the records where the date, employee id, total hours, job type and clinic are the same as the data the user is trying to submit.
I then have an if statement like this:
[tt]
if dm_global.qry_check_dup.RecordCount > 0 then
begin
MessageDlg('This entry has already been saved',mtWarning,[mbok],0);
frm_input_hours2.Refresh;
end
[/tt]
It checks to see if the record count with the specific data is more than zero. If it is it returns a warning. If it is not, it posts the data.
The problem I'm having is when I test this and try to post data I receive the following error:
[tt]
Project timekeeping.exe raised exception class EDatabaseError with message 'qry_check_dup:Field 'date' not found'
[/tt]
I don't have any problems with the date field in the other queries so I am confused. Does this have something to do with the COUNT function? I've got to be doing something wrong. I'm just not sure where.
Any suggestions would be appreciated.
I am using a query to check our existing records in the employee time table when the 'Save Record' button is pressed. The query looks like this:
[tt]SELECT COUNT(*)
FROM "EMP_TIME.DBF" Emp_time
WHERE (Emp_time."date" = :cdate)
AND (prempl =
AND (total_hours = :total_hours)
AND (job_type = :job_type)
AND (clinic = :clinic)[/tt]
As you can tell I'm trying to count the records where the date, employee id, total hours, job type and clinic are the same as the data the user is trying to submit.
I then have an if statement like this:
[tt]
if dm_global.qry_check_dup.RecordCount > 0 then
begin
MessageDlg('This entry has already been saved',mtWarning,[mbok],0);
frm_input_hours2.Refresh;
end
[/tt]
It checks to see if the record count with the specific data is more than zero. If it is it returns a warning. If it is not, it posts the data.
The problem I'm having is when I test this and try to post data I receive the following error:
[tt]
Project timekeeping.exe raised exception class EDatabaseError with message 'qry_check_dup:Field 'date' not found'
[/tt]
I don't have any problems with the date field in the other queries so I am confused. Does this have something to do with the COUNT function? I've got to be doing something wrong. I'm just not sure where.
Any suggestions would be appreciated.