
February 11th, 2004, 11:36 PM
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Count record given conditions;save back to table
Hello all,
I'm working with a multi-user front-end/back-end relational database. I'm trying to use VBA to count records given specific criteria, and have the value saved back to a table (whose only function is to store these values). Simplified description:
One table holds personnel data for multiple companies (name, company, etc) and a second holds training data, linked on unique field.
Conditions for count are:
SELECT Table1.Name, Table1.Company, Table1.record_valid, Table2.training_variable
FROM Table1 INNER JOIN Table2 ON Table1.Unique_ID = Table2.Unique_ID
WHERE (((Table1.Company)=[criteria]) AND ((Table1.record_valid)=Yes) AND ((Table2.training_variable)<=Date()-410 Or (Table2.training_variable) Is Null));
While the query above works, it's not flexible enough; the code will need to return multiple counts, as there are 17 different training requirements. I need to simply count the number of people requiring each training and pass them back to a table. I'm trying to avoid running 17 queries...
The process defines currency as annual + 45 days; this should give a count of anyone for whom more than 410 days have passed, PLUS those who have no dates listed at all. In addition, certain employees' records are maintained after they depart the company, so the recordset must contain only valid employees of the given company (criteria).
Since I know how fun (!) it can be to try to "virtually" work things out without having actual data with which to work, here's something like what a result should be given conditions:
If there are 5000 total records, with 600 of them being in the correct company, and 100 of those being "non current employees", the total number of records being compared will be 500. If 300 of these have had the training in the last 410 days, and 100 people have NO date listed at all, the end count should be 200 (100 overdue and 100 Null values). Sorry for the long post; hope this makes sense...and thanks in advance.
|