Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check table before data entry

Status
Not open for further replies.

fadMiS

MIS
Jan 12, 2004
13
YU
I have created payroll database and I have table "Salaries" with EmployeeID (number), PayDate (date) and other fileds. I have form for calculating of salaries (with txtEmployeeID, txtPayDate) but before i store data in Salary table i need to check whether salary is already entered in table "Salaries". I need to check EmployeeID and PayDate fields in Salary so operator could not preceed if salary for any employee is already entered. This could be done having EmployeeID and PayDate as primary Key (system would give duplicate error) but I need to do it programatically with dlookup or any VBA function or module.

fad


 
There are probably much better ways to do this but how about creating a recordset based on a query of the salary table that uses the EmployeeID and PayDate from your form as criteria.

Then test how many records are in the resulting recordset, zero would mean OK to enter the data, 1 would mean a record was already in salary table for that employee/date combination and you could abort.

Hope this helps

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top