Database Help!

G

GMac

Hello,

I am trying to figure out my next route to obtain my desired outcome.
I have started a database, and have a table with associate information, a
table with training data (associate id, training code, date) and a table with
certificate information(certificate code,certificate name, training required
for certificate) .

The training data is entered in the database on a weekly basis. Each
certificate requires different amounts of training in order to earn the
certificate.

I would like to set up a query that looks at each associates training and
detemines when the criteria for the certificate is earned. How would I set
this up? It would be nice if the outcome of this would show the associates
name and number on the report along with certificates earned based on the
training each associate has taken.

Please any help would be great!
greg
 
M

Michel Walsh

Wrong table design, I think. I suggest:


Certificates CertificateID CertificateName
1 The Basic one
2 Some other
3 Another certificate




Trainings TrainingID TrainingName
1 TrainingA
2 TrainingB
3 TrainingC
4 TrainingD



Requirements certificateID trainingID
1 1
1 2
1 3
2 1
2 3
3 1
3 2
3 4





Employee EmployeeID EmployeeName
1 Joe
2 Julie
3 John
4 Tom




EmployeeTrainings EmployeeID TrainingID
1 1
1 2
1 3
1 4
2 1
2 4
3 1
3 2
3 3
4 2
4 3
4 4




then

SELECT Employee.EmployeeName, Certificates.CertificateName, a.certificateID

FROM ((EmployeeTrainings INNER JOIN Requirements AS a ON EmployeeTrainings.TrainingID = a.trainingID)
INNER JOIN Employee ON EmployeeTrainings.EmployeeID = Employee.EmployeeID)
INNER JOIN Certificates ON a.certificateID = Certificates.CertificateID

GROUP BY Employee.EmployeeName, Certificates.CertificateName, a.certificateID
HAVING (((Count(*))=(SELECT COUNT(*) FROM Requirements WHERE certificateID=a.certificateID)));


result into:


Query2 EmployeeName CertificateName certificateID
Joe Another certificate 3
Joe Some other 2
Joe The Basic one 1
John Some other 2
John The Basic one 1






Hoping it may help,
Vanderghast, Access MVP
 
G

GMac

Michel,

This sounds like it will work, I think I need to set up my exsiting tables
so that they match up with the training tables like you said. I thought I had
done that, but your version seems to be a lot better.

My main question, is where to enter the code you have given me? Is that in a
query? Two queries? Where, and how do I enter it? I have never used code that
extensive. Could you please explain the table's you have listed so I make
sure I am on the right track?

Thanks for your help!
 
M

Michel Walsh

The code is just one query, enter the code in SQL view.

The tables that are not obvious are EmployeeTrainings and Requirements.

EmployeeTrainings list each training that each employee got, on pair by
record, no duplicated pairs.

Requirements is a table that list all the trainings needed to get one
certificate, but, again only one (training-certificate pair) per record, no
duplicated pairs.

Other tables are just there to convert numbers_id into meaningful text
description.


Hoping it may help,
Vanderghast, Access MVP
 
G

GMac

Michel,
OK, I was right on what I did. I entered thr code in SQL view with the
correct names of my tables. I am getting a syntax error in the JOIN operation
that I can't figure out. Here is the code: Any ideas?

SELECT [tbl Associate]. [Associate #], [First Name], [Last Name], [tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate number] = [tbl
associate]. [associate #]
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate. associate #, First Name, Last Name, tbl
certificates. certificate, a.certificate code
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE certificate code =
a.certificate code)));


Thanks,
greg
 
M

Michel Walsh

A ) is missing before the last INNER JOIN.

The GROUP BY clause need [ ] around the illegal fields name:

GROUP BY tbl Associate.[associate #], [First Name], [Last Name],
tblcertificates.certificate, a.[certificate code]


and also in the WHERE clause of the sub-query in the main HAVING clause:
a.[certificate code]

.... a good reason to NOT use illegal names for fields (use the caption
property, if you want names easy to read, automatically displayed on user
interface).



Hoping it may help,
Vanderghast, Access MVP


GMac said:
Michel,
OK, I was right on what I did. I entered thr code in SQL view with the
correct names of my tables. I am getting a syntax error in the JOIN
operation
that I can't figure out. Here is the code: Any ideas?

SELECT [tbl Associate]. [Associate #], [First Name], [Last Name], [tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate number] = [tbl
associate]. [associate #]
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate. associate #, First Name, Last Name, tbl
certificates. certificate, a.certificate code
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE certificate code
=
a.certificate code)));


Thanks,
greg

Michel Walsh said:
The code is just one query, enter the code in SQL view.

The tables that are not obvious are EmployeeTrainings and Requirements.

EmployeeTrainings list each training that each employee got, on pair by
record, no duplicated pairs.

Requirements is a table that list all the trainings needed to get one
certificate, but, again only one (training-certificate pair) per record,
no
duplicated pairs.

Other tables are just there to convert numbers_id into meaningful text
description.


Hoping it may help,
Vanderghast, Access MVP
 
G

GMac

Michel,

Upon correcting the errors you have listed, I get this:

Invalid use of '.','!', or '( )' in Query Expression [tbl data entry] .
[training code] = a.[training code] I occured when I entered the missing )
you had listed. My code looks like this now:
SELECT [tbl Associate]. [Associate #], [First Name], [Last Name], [tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate number] = [tbl
associate]. [associate #])
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate.[associate #],[ First Name], [Last Name], tbl
certificates. certificate, a.[certificate code]
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE certificate code
= a.[certificate code])));

Thanks again for all your help, this thing is driving me crazy!
greg



Michel Walsh said:
A ) is missing before the last INNER JOIN.

The GROUP BY clause need [ ] around the illegal fields name:

GROUP BY tbl Associate.[associate #], [First Name], [Last Name],
tblcertificates.certificate, a.[certificate code]


and also in the WHERE clause of the sub-query in the main HAVING clause:
a.[certificate code]

.... a good reason to NOT use illegal names for fields (use the caption
property, if you want names easy to read, automatically displayed on user
interface).



Hoping it may help,
Vanderghast, Access MVP


GMac said:
Michel,
OK, I was right on what I did. I entered thr code in SQL view with the
correct names of my tables. I am getting a syntax error in the JOIN
operation
that I can't figure out. Here is the code: Any ideas?

SELECT [tbl Associate]. [Associate #], [First Name], [Last Name], [tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate number] = [tbl
associate]. [associate #]
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate. associate #, First Name, Last Name, tbl
certificates. certificate, a.certificate code
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE certificate code
=
a.certificate code)));


Thanks,
greg

Michel Walsh said:
The code is just one query, enter the code in SQL view.

The tables that are not obvious are EmployeeTrainings and Requirements.

EmployeeTrainings list each training that each employee got, on pair by
record, no duplicated pairs.

Requirements is a table that list all the trainings needed to get one
certificate, but, again only one (training-certificate pair) per record,
no
duplicated pairs.

Other tables are just there to convert numbers_id into meaningful text
description.


Hoping it may help,
Vanderghast, Access MVP



Michel,

This sounds like it will work, I think I need to set up my exsiting
tables
so that they match up with the training tables like you said. I thought
I
had
done that, but your version seems to be a lot better.

My main question, is where to enter the code you have given me? Is that
in
a
query? Two queries? Where, and how do I enter it? I have never used
code
that
extensive. Could you please explain the table's you have listed so I
make
sure I am on the right track?

Thanks for your help!

:

Wrong table design, I think. I suggest:


Certificates CertificateID CertificateName
1 The Basic one
2 Some other
3 Another certificate




Trainings TrainingID TrainingName
1 TrainingA
2 TrainingB
3 TrainingC
4 TrainingD



Requirements certificateID trainingID
1 1
1 2
1 3
2 1
2 3
3 1
3 2
3 4





Employee EmployeeID EmployeeName
1 Joe
2 Julie
3 John
4 Tom




EmployeeTrainings EmployeeID TrainingID
1 1
1 2
1 3
1 4
2 1
2 4
3 1
3 2
3 3
4 2
4 3
4 4




then

SELECT Employee.EmployeeName, Certificates.CertificateName,
a.certificateID

FROM ((EmployeeTrainings INNER JOIN Requirements AS a ON
EmployeeTrainings.TrainingID = a.trainingID)
INNER JOIN Employee ON EmployeeTrainings.EmployeeID =
Employee.EmployeeID)
INNER JOIN Certificates ON a.certificateID =
Certificates.CertificateID

GROUP BY Employee.EmployeeName, Certificates.CertificateName,
a.certificateID
HAVING (((Count(*))=(SELECT COUNT(*) FROM Requirements WHERE
certificateID=a.certificateID)));


result into:


Query2 EmployeeName CertificateName certificateID
Joe Another certificate 3
Joe Some other 2
Joe The Basic one 1
John Some other 2
John The Basic one 1






Hoping it may help,
Vanderghast, Access MVP


Hello,

I am trying to figure out my next route to obtain my desired
outcome.
I have started a database, and have a table with associate
information,
a
table with training data (associate id, training code, date) and a
table with
certificate information(certificate code,certificate name, training
required
for certificate) .

The training data is entered in the database on a weekly basis. Each
certificate requires different amounts of training in order to earn
the
certificate.

I would like to set up a query that looks at each associates
training
and
detemines when the criteria for the certificate is earned. How would
I
set
this up? It would be nice if the outcome of this would show the
associates
name and number on the report along with certificates earned based
on
the
training each associate has taken.

Please any help would be great!
greg
 
G

Gary Walter

there should be no space on either side of
decimal point...maybe get you closer...

SELECT
[tbl Associate].[Associate #],
[First Name],
[Last Name],
[tbl Certificates].[Certificate],
a.[Certificate code]
FROM
(
(
[tbl data entry]
INNER JOIN
[tbl Labs] AS a
ON
[tbl data entry].[training code] = a.[training code]
)
INNER JOIN
[tbl Associate]
ON
[tbl data entry].[associate number] = [tbl associate].[associate #]
)
INNER JOIN
[tbl certificates]
ON
a.[certificate code] = [tbl certificates].[certificate code]
GROUP BY
[tbl Associate].[associate #],
[ First Name],
[Last Name],
[tbl certificates].certificate,
a.[certificate code]
HAVING
((count(*)) =
(SELECT
COUNT(*)
FROM [tbl labs]
WHERE
[certificate code] = a.[certificate code])));


"GMac" > Michel,
Upon correcting the errors you have listed, I get this:

Invalid use of '.','!', or '( )' in Query Expression [tbl data entry] .
[training code] = a.[training code] I occured when I entered the missing )
you had listed. My code looks like this now:
SELECT [tbl Associate]. [Associate #], [First Name], [Last Name], [tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate number] = [tbl
associate]. [associate #])
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate.[associate #],[ First Name], [Last Name], tbl
certificates. certificate, a.[certificate code]
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE certificate code
= a.[certificate code])));

Thanks again for all your help, this thing is driving me crazy!
greg



Michel Walsh said:
A ) is missing before the last INNER JOIN.

The GROUP BY clause need [ ] around the illegal fields name:

GROUP BY tbl Associate.[associate #], [First Name], [Last Name],
tblcertificates.certificate, a.[certificate code]


and also in the WHERE clause of the sub-query in the main HAVING clause:
a.[certificate code]

.... a good reason to NOT use illegal names for fields (use the caption
property, if you want names easy to read, automatically displayed on user
interface).



Hoping it may help,
Vanderghast, Access MVP


GMac said:
Michel,
OK, I was right on what I did. I entered thr code in SQL view with the
correct names of my tables. I am getting a syntax error in the JOIN
operation
that I can't figure out. Here is the code: Any ideas?

SELECT [tbl Associate]. [Associate #], [First Name], [Last Name], [tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate number] =
[tbl
associate]. [associate #]
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate. associate #, First Name, Last Name, tbl
certificates. certificate, a.certificate code
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE certificate
code
=
a.certificate code)));


Thanks,
greg

:

The code is just one query, enter the code in SQL view.

The tables that are not obvious are EmployeeTrainings and
Requirements.

EmployeeTrainings list each training that each employee got, on pair
by
record, no duplicated pairs.

Requirements is a table that list all the trainings needed to get one
certificate, but, again only one (training-certificate pair) per
record,
no
duplicated pairs.

Other tables are just there to convert numbers_id into meaningful text
description.


Hoping it may help,
Vanderghast, Access MVP



Michel,

This sounds like it will work, I think I need to set up my exsiting
tables
so that they match up with the training tables like you said. I
thought
I
had
done that, but your version seems to be a lot better.

My main question, is where to enter the code you have given me? Is
that
in
a
query? Two queries? Where, and how do I enter it? I have never used
code
that
extensive. Could you please explain the table's you have listed so I
make
sure I am on the right track?

Thanks for your help!

:

Wrong table design, I think. I suggest:


Certificates CertificateID CertificateName
1 The Basic one
2 Some other
3 Another certificate




Trainings TrainingID TrainingName
1 TrainingA
2 TrainingB
3 TrainingC
4 TrainingD



Requirements certificateID trainingID
1 1
1 2
1 3
2 1
2 3
3 1
3 2
3 4





Employee EmployeeID EmployeeName
1 Joe
2 Julie
3 John
4 Tom




EmployeeTrainings EmployeeID TrainingID
1 1
1 2
1 3
1 4
2 1
2 4
3 1
3 2
3 3
4 2
4 3
4 4




then

SELECT Employee.EmployeeName, Certificates.CertificateName,
a.certificateID

FROM ((EmployeeTrainings INNER JOIN Requirements AS a ON
EmployeeTrainings.TrainingID = a.trainingID)
INNER JOIN Employee ON EmployeeTrainings.EmployeeID =
Employee.EmployeeID)
INNER JOIN Certificates ON a.certificateID =
Certificates.CertificateID

GROUP BY Employee.EmployeeName, Certificates.CertificateName,
a.certificateID
HAVING (((Count(*))=(SELECT COUNT(*) FROM Requirements WHERE
certificateID=a.certificateID)));


result into:


Query2 EmployeeName CertificateName certificateID
Joe Another certificate 3
Joe Some other 2
Joe The Basic one 1
John Some other 2
John The Basic one 1






Hoping it may help,
Vanderghast, Access MVP


Hello,

I am trying to figure out my next route to obtain my desired
outcome.
I have started a database, and have a table with associate
information,
a
table with training data (associate id, training code, date) and
a
table with
certificate information(certificate code,certificate name,
training
required
for certificate) .

The training data is entered in the database on a weekly basis.
Each
certificate requires different amounts of training in order to
earn
the
certificate.

I would like to set up a query that looks at each associates
training
and
detemines when the criteria for the certificate is earned. How
would
I
set
this up? It would be nice if the outcome of this would show the
associates
name and number on the report along with certificates earned
based
on
the
training each associate has taken.

Please any help would be great!
greg
 
G

GMac

Ok.......I got the query to work, but there is still a problem. When I run
the query it is asking for a training code. Why?
And the query results are not right. It is listing all certificates for each
associate instead of looking at the training codes and seeing if each
associate has met the criteria for each certificate. example certificate A
needs training codes A,B,C,D to be complete in order for certificate A to be
earned. The data entry table lists all training codes completed by each
associate. I think I'm getting closer, but still need help!

Thanks

Gary Walter said:
there should be no space on either side of
decimal point...maybe get you closer...

SELECT
[tbl Associate].[Associate #],
[First Name],
[Last Name],
[tbl Certificates].[Certificate],
a.[Certificate code]
FROM
(
(
[tbl data entry]
INNER JOIN
[tbl Labs] AS a
ON
[tbl data entry].[training code] = a.[training code]
)
INNER JOIN
[tbl Associate]
ON
[tbl data entry].[associate number] = [tbl associate].[associate #]
)
INNER JOIN
[tbl certificates]
ON
a.[certificate code] = [tbl certificates].[certificate code]
GROUP BY
[tbl Associate].[associate #],
[ First Name],
[Last Name],
[tbl certificates].certificate,
a.[certificate code]
HAVING
((count(*)) =
(SELECT
COUNT(*)
FROM [tbl labs]
WHERE
[certificate code] = a.[certificate code])));


"GMac" > Michel,
Upon correcting the errors you have listed, I get this:

Invalid use of '.','!', or '( )' in Query Expression [tbl data entry] .
[training code] = a.[training code] I occured when I entered the missing )
you had listed. My code looks like this now:
SELECT [tbl Associate]. [Associate #], [First Name], [Last Name], [tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate number] = [tbl
associate]. [associate #])
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate.[associate #],[ First Name], [Last Name], tbl
certificates. certificate, a.[certificate code]
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE certificate code
= a.[certificate code])));

Thanks again for all your help, this thing is driving me crazy!
greg



Michel Walsh said:
A ) is missing before the last INNER JOIN.

The GROUP BY clause need [ ] around the illegal fields name:

GROUP BY tbl Associate.[associate #], [First Name], [Last Name],
tblcertificates.certificate, a.[certificate code]


and also in the WHERE clause of the sub-query in the main HAVING clause:
a.[certificate code]

.... a good reason to NOT use illegal names for fields (use the caption
property, if you want names easy to read, automatically displayed on user
interface).



Hoping it may help,
Vanderghast, Access MVP


Michel,
OK, I was right on what I did. I entered thr code in SQL view with the
correct names of my tables. I am getting a syntax error in the JOIN
operation
that I can't figure out. Here is the code: Any ideas?

SELECT [tbl Associate]. [Associate #], [First Name], [Last Name], [tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate number] =
[tbl
associate]. [associate #]
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate. associate #, First Name, Last Name, tbl
certificates. certificate, a.certificate code
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE certificate
code
=
a.certificate code)));


Thanks,
greg

:

The code is just one query, enter the code in SQL view.

The tables that are not obvious are EmployeeTrainings and
Requirements.

EmployeeTrainings list each training that each employee got, on pair
by
record, no duplicated pairs.

Requirements is a table that list all the trainings needed to get one
certificate, but, again only one (training-certificate pair) per
record,
no
duplicated pairs.

Other tables are just there to convert numbers_id into meaningful text
description.


Hoping it may help,
Vanderghast, Access MVP



Michel,

This sounds like it will work, I think I need to set up my exsiting
tables
so that they match up with the training tables like you said. I
thought
I
had
done that, but your version seems to be a lot better.

My main question, is where to enter the code you have given me? Is
that
in
a
query? Two queries? Where, and how do I enter it? I have never used
code
that
extensive. Could you please explain the table's you have listed so I
make
sure I am on the right track?

Thanks for your help!

:

Wrong table design, I think. I suggest:


Certificates CertificateID CertificateName
1 The Basic one
2 Some other
3 Another certificate




Trainings TrainingID TrainingName
1 TrainingA
2 TrainingB
3 TrainingC
4 TrainingD



Requirements certificateID trainingID
1 1
1 2
1 3
2 1
2 3
3 1
3 2
3 4





Employee EmployeeID EmployeeName
1 Joe
2 Julie
3 John
4 Tom




EmployeeTrainings EmployeeID TrainingID
1 1
1 2
1 3
1 4
2 1
2 4
3 1
3 2
3 3
4 2
4 3
4 4




then

SELECT Employee.EmployeeName, Certificates.CertificateName,
a.certificateID

FROM ((EmployeeTrainings INNER JOIN Requirements AS a ON
EmployeeTrainings.TrainingID = a.trainingID)
INNER JOIN Employee ON EmployeeTrainings.EmployeeID =
Employee.EmployeeID)
INNER JOIN Certificates ON a.certificateID =
Certificates.CertificateID

GROUP BY Employee.EmployeeName, Certificates.CertificateName,
a.certificateID
HAVING (((Count(*))=(SELECT COUNT(*) FROM Requirements WHERE
certificateID=a.certificateID)));


result into:


Query2 EmployeeName CertificateName certificateID
Joe Another certificate 3
Joe Some other 2
Joe The Basic one 1
John Some other 2
John The Basic one 1






Hoping it may help,
Vanderghast, Access MVP


Hello,

I am trying to figure out my next route to obtain my desired
outcome.
I have started a database, and have a table with associate
information,
a
table with training data (associate id, training code, date) and
a
table with
certificate information(certificate code,certificate name,
training
required
for certificate) .

The training data is entered in the database on a weekly basis.
Each
certificate requires different amounts of training in order to
earn
the
certificate.

I would like to set up a query that looks at each associates
training
and
detemines when the criteria for the certificate is earned. How
would
I
set
this up? It would be nice if the outcome of this would show the
associates
 
G

Gary Walter

Open [tbl data entry] in design mode
and see how spelled "training code"

Open [tbl Labs] in design mode
and see how spelled "training code"

adjust to correct spelling in

[tbl data entry].[training code] = a.[training code]


"GMac"wrote:
Ok.......I got the query to work, but there is still a problem. When I run
the query it is asking for a training code. Why?
And the query results are not right. It is listing all certificates for
each
associate instead of looking at the training codes and seeing if each
associate has met the criteria for each certificate. example certificate A
needs training codes A,B,C,D to be complete in order for certificate A to
be
earned. The data entry table lists all training codes completed by each
associate. I think I'm getting closer, but still need help!

Thanks

Gary Walter said:
there should be no space on either side of
decimal point...maybe get you closer...

SELECT
[tbl Associate].[Associate #],
[First Name],
[Last Name],
[tbl Certificates].[Certificate],
a.[Certificate code]
FROM
(
(
[tbl data entry]
INNER JOIN
[tbl Labs] AS a
ON
[tbl data entry].[training code] = a.[training code]
)
INNER JOIN
[tbl Associate]
ON
[tbl data entry].[associate number] = [tbl associate].[associate #]
)
INNER JOIN
[tbl certificates]
ON
a.[certificate code] = [tbl certificates].[certificate code]
GROUP BY
[tbl Associate].[associate #],
[ First Name],
[Last Name],
[tbl certificates].certificate,
a.[certificate code]
HAVING
((count(*)) =
(SELECT
COUNT(*)
FROM [tbl labs]
WHERE
[certificate code] = a.[certificate code])));


"GMac" > Michel,
Upon correcting the errors you have listed, I get this:

Invalid use of '.','!', or '( )' in Query Expression [tbl data entry] .
[training code] = a.[training code] I occured when I entered the
missing )
you had listed. My code looks like this now:
SELECT [tbl Associate]. [Associate #], [First Name], [Last Name], [tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate number] =
[tbl
associate]. [associate #])
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate.[associate #],[ First Name], [Last Name], tbl
certificates. certificate, a.[certificate code]
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE certificate
code
= a.[certificate code])));

Thanks again for all your help, this thing is driving me crazy!
greg



:

A ) is missing before the last INNER JOIN.

The GROUP BY clause need [ ] around the illegal fields name:

GROUP BY tbl Associate.[associate #], [First Name], [Last Name],
tblcertificates.certificate, a.[certificate code]


and also in the WHERE clause of the sub-query in the main HAVING
clause:
a.[certificate code]

.... a good reason to NOT use illegal names for fields (use the
caption
property, if you want names easy to read, automatically displayed on
user
interface).



Hoping it may help,
Vanderghast, Access MVP


Michel,
OK, I was right on what I did. I entered thr code in SQL view with
the
correct names of my tables. I am getting a syntax error in the JOIN
operation
that I can't figure out. Here is the code: Any ideas?

SELECT [tbl Associate]. [Associate #], [First Name], [Last Name],
[tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data
entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate number] =
[tbl
associate]. [associate #]
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate. associate #, First Name, Last Name, tbl
certificates. certificate, a.certificate code
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE
certificate
code
=
a.certificate code)));


Thanks,
greg

:

The code is just one query, enter the code in SQL view.

The tables that are not obvious are EmployeeTrainings and
Requirements.

EmployeeTrainings list each training that each employee got, on
pair
by
record, no duplicated pairs.

Requirements is a table that list all the trainings needed to get
one
certificate, but, again only one (training-certificate pair) per
record,
no
duplicated pairs.

Other tables are just there to convert numbers_id into meaningful
text
description.


Hoping it may help,
Vanderghast, Access MVP



Michel,

This sounds like it will work, I think I need to set up my
exsiting
tables
so that they match up with the training tables like you said. I
thought
I
had
done that, but your version seems to be a lot better.

My main question, is where to enter the code you have given me?
Is
that
in
a
query? Two queries? Where, and how do I enter it? I have never
used
code
that
extensive. Could you please explain the table's you have listed
so I
make
sure I am on the right track?

Thanks for your help!

:

Wrong table design, I think. I suggest:


Certificates CertificateID CertificateName
1 The Basic one
2 Some other
3 Another certificate




Trainings TrainingID TrainingName
1 TrainingA
2 TrainingB
3 TrainingC
4 TrainingD



Requirements certificateID trainingID
1 1
1 2
1 3
2 1
2 3
3 1
3 2
3 4





Employee EmployeeID EmployeeName
1 Joe
2 Julie
3 John
4 Tom




EmployeeTrainings EmployeeID TrainingID
1 1
1 2
1 3
1 4
2 1
2 4
3 1
3 2
3 3
4 2
4 3
4 4




then

SELECT Employee.EmployeeName, Certificates.CertificateName,
a.certificateID

FROM ((EmployeeTrainings INNER JOIN Requirements AS a ON
EmployeeTrainings.TrainingID = a.trainingID)
INNER JOIN Employee ON EmployeeTrainings.EmployeeID =
Employee.EmployeeID)
INNER JOIN Certificates ON a.certificateID =
Certificates.CertificateID

GROUP BY Employee.EmployeeName, Certificates.CertificateName,
a.certificateID
HAVING (((Count(*))=(SELECT COUNT(*) FROM Requirements WHERE
certificateID=a.certificateID)));


result into:


Query2 EmployeeName CertificateName certificateID
Joe Another certificate 3
Joe Some other 2
Joe The Basic one 1
John Some other 2
John The Basic one 1






Hoping it may help,
Vanderghast, Access MVP


Hello,

I am trying to figure out my next route to obtain my desired
outcome.
I have started a database, and have a table with associate
information,
a
table with training data (associate id, training code, date)
and
a
table with
certificate information(certificate code,certificate name,
training
required
for certificate) .

The training data is entered in the database on a weekly
basis.
Each
certificate requires different amounts of training in order to
earn
the
certificate.

I would like to set up a query that looks at each associates
training
and
detemines when the criteria for the certificate is earned. How
would
I
set
this up? It would be nice if the outcome of this would show
the
associates
 
G

GMac

Thanks Gary,
It worked. One problem I found is that if there is a duplicate value (which
happens) in the data entry for an associate, then they do not show up in the
query results.

Would I have to change the count to maybe Dcount?

greg

Gary Walter said:
Open [tbl data entry] in design mode
and see how spelled "training code"

Open [tbl Labs] in design mode
and see how spelled "training code"

adjust to correct spelling in

[tbl data entry].[training code] = a.[training code]


"GMac"wrote:
Ok.......I got the query to work, but there is still a problem. When I run
the query it is asking for a training code. Why?
And the query results are not right. It is listing all certificates for
each
associate instead of looking at the training codes and seeing if each
associate has met the criteria for each certificate. example certificate A
needs training codes A,B,C,D to be complete in order for certificate A to
be
earned. The data entry table lists all training codes completed by each
associate. I think I'm getting closer, but still need help!

Thanks

Gary Walter said:
there should be no space on either side of
decimal point...maybe get you closer...

SELECT
[tbl Associate].[Associate #],
[First Name],
[Last Name],
[tbl Certificates].[Certificate],
a.[Certificate code]
FROM
(
(
[tbl data entry]
INNER JOIN
[tbl Labs] AS a
ON
[tbl data entry].[training code] = a.[training code]
)
INNER JOIN
[tbl Associate]
ON
[tbl data entry].[associate number] = [tbl associate].[associate #]
)
INNER JOIN
[tbl certificates]
ON
a.[certificate code] = [tbl certificates].[certificate code]
GROUP BY
[tbl Associate].[associate #],
[ First Name],
[Last Name],
[tbl certificates].certificate,
a.[certificate code]
HAVING
((count(*)) =
(SELECT
COUNT(*)
FROM [tbl labs]
WHERE
[certificate code] = a.[certificate code])));


"GMac" > Michel,

Upon correcting the errors you have listed, I get this:

Invalid use of '.','!', or '( )' in Query Expression [tbl data entry] .
[training code] = a.[training code] I occured when I entered the
missing )
you had listed. My code looks like this now:
SELECT [tbl Associate]. [Associate #], [First Name], [Last Name], [tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate number] =
[tbl
associate]. [associate #])
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate.[associate #],[ First Name], [Last Name], tbl
certificates. certificate, a.[certificate code]
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE certificate
code
= a.[certificate code])));

Thanks again for all your help, this thing is driving me crazy!
greg



:

A ) is missing before the last INNER JOIN.

The GROUP BY clause need [ ] around the illegal fields name:

GROUP BY tbl Associate.[associate #], [First Name], [Last Name],
tblcertificates.certificate, a.[certificate code]


and also in the WHERE clause of the sub-query in the main HAVING
clause:
a.[certificate code]

.... a good reason to NOT use illegal names for fields (use the
caption
property, if you want names easy to read, automatically displayed on
user
interface).



Hoping it may help,
Vanderghast, Access MVP


Michel,
OK, I was right on what I did. I entered thr code in SQL view with
the
correct names of my tables. I am getting a syntax error in the JOIN
operation
that I can't figure out. Here is the code: Any ideas?

SELECT [tbl Associate]. [Associate #], [First Name], [Last Name],
[tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data
entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate number] =
[tbl
associate]. [associate #]
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate. associate #, First Name, Last Name, tbl
certificates. certificate, a.certificate code
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE
certificate
code
=
a.certificate code)));


Thanks,
greg

:

The code is just one query, enter the code in SQL view.

The tables that are not obvious are EmployeeTrainings and
Requirements.

EmployeeTrainings list each training that each employee got, on
pair
by
record, no duplicated pairs.

Requirements is a table that list all the trainings needed to get
one
certificate, but, again only one (training-certificate pair) per
record,
no
duplicated pairs.

Other tables are just there to convert numbers_id into meaningful
text
description.


Hoping it may help,
Vanderghast, Access MVP



Michel,

This sounds like it will work, I think I need to set up my
exsiting
tables
so that they match up with the training tables like you said. I
thought
I
had
done that, but your version seems to be a lot better.

My main question, is where to enter the code you have given me?
Is
that
in
a
query? Two queries? Where, and how do I enter it? I have never
used
code
that
extensive. Could you please explain the table's you have listed
so I
make
sure I am on the right track?

Thanks for your help!

:

Wrong table design, I think. I suggest:


Certificates CertificateID CertificateName
1 The Basic one
2 Some other
3 Another certificate




Trainings TrainingID TrainingName
1 TrainingA
2 TrainingB
3 TrainingC
4 TrainingD



Requirements certificateID trainingID
1 1
1 2
1 3
2 1
2 3
3 1
3 2
3 4





Employee EmployeeID EmployeeName
1 Joe
2 Julie
3 John
4 Tom




EmployeeTrainings EmployeeID TrainingID
1 1
1 2
1 3
1 4
2 1
2 4
3 1
3 2
3 3
4 2
4 3
4 4




then

SELECT Employee.EmployeeName, Certificates.CertificateName,
a.certificateID

FROM ((EmployeeTrainings INNER JOIN Requirements AS a ON
EmployeeTrainings.TrainingID = a.trainingID)
INNER JOIN Employee ON EmployeeTrainings.EmployeeID =
Employee.EmployeeID)
INNER JOIN Certificates ON a.certificateID =
Certificates.CertificateID

GROUP BY Employee.EmployeeName, Certificates.CertificateName,
a.certificateID
HAVING (((Count(*))=(SELECT COUNT(*) FROM Requirements WHERE
certificateID=a.certificateID)));


result into:


Query2 EmployeeName CertificateName certificateID
Joe Another certificate 3
Joe Some other 2
Joe The Basic one 1
John Some other 2
 
M

Michel Walsh

Nope, you have to built an index that forbid duplicated pairs.

To build an index on more than a single field, open the table in design
view, open the index window,

- give a name for the index, in the first column,
- type one of the field making the index in the second column
- specify an ordering, if wanted
- in the bottom left, change the Unique from No to Yes

- get to the next line in the grid, but type nothing in the first
column,
- specify another field in the second column


That will create an index forbidding duplicated pairs (of field). Sure, if
your table already have duplicated pair, Access won't let you save the
design. So, be sure you don't have duplicate pairs, first.



The two junctions tables, those I named Requirements and
EmployeeTrainings, MUST NOT have duplicated pairs: after all, a certificate
does not ask you take the a given training twice; neither is it expected to
have an employee completing with success the same training twice



Hoping it may help,
Vanderghast, Access MVP



GMac said:
Thanks Gary,
It worked. One problem I found is that if there is a duplicate value
(which
happens) in the data entry for an associate, then they do not show up in
the
query results.

Would I have to change the count to maybe Dcount?

greg

Gary Walter said:
Open [tbl data entry] in design mode
and see how spelled "training code"

Open [tbl Labs] in design mode
and see how spelled "training code"

adjust to correct spelling in

[tbl data entry].[training code] = a.[training code]


"GMac"wrote:
Ok.......I got the query to work, but there is still a problem. When I
run
the query it is asking for a training code. Why?
And the query results are not right. It is listing all certificates for
each
associate instead of looking at the training codes and seeing if each
associate has met the criteria for each certificate. example
certificate A
needs training codes A,B,C,D to be complete in order for certificate A
to
be
earned. The data entry table lists all training codes completed by each
associate. I think I'm getting closer, but still need help!

Thanks

:

there should be no space on either side of
decimal point...maybe get you closer...

SELECT
[tbl Associate].[Associate #],
[First Name],
[Last Name],
[tbl Certificates].[Certificate],
a.[Certificate code]
FROM
(
(
[tbl data entry]
INNER JOIN
[tbl Labs] AS a
ON
[tbl data entry].[training code] = a.[training code]
)
INNER JOIN
[tbl Associate]
ON
[tbl data entry].[associate number] = [tbl associate].[associate #]
)
INNER JOIN
[tbl certificates]
ON
a.[certificate code] = [tbl certificates].[certificate code]
GROUP BY
[tbl Associate].[associate #],
[ First Name],
[Last Name],
[tbl certificates].certificate,
a.[certificate code]
HAVING
((count(*)) =
(SELECT
COUNT(*)
FROM [tbl labs]
WHERE
[certificate code] = a.[certificate code])));


"GMac" > Michel,

Upon correcting the errors you have listed, I get this:

Invalid use of '.','!', or '( )' in Query Expression [tbl data
entry] .
[training code] = a.[training code] I occured when I entered the
missing )
you had listed. My code looks like this now:
SELECT [tbl Associate]. [Associate #], [First Name], [Last Name],
[tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data
entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate number] =
[tbl
associate]. [associate #])
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate.[associate #],[ First Name], [Last Name], tbl
certificates. certificate, a.[certificate code]
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE
certificate
code
= a.[certificate code])));

Thanks again for all your help, this thing is driving me crazy!
greg



:

A ) is missing before the last INNER JOIN.

The GROUP BY clause need [ ] around the illegal fields name:

GROUP BY tbl Associate.[associate #], [First Name], [Last Name],
tblcertificates.certificate, a.[certificate code]


and also in the WHERE clause of the sub-query in the main HAVING
clause:
a.[certificate code]

.... a good reason to NOT use illegal names for fields (use the
caption
property, if you want names easy to read, automatically displayed
on
user
interface).



Hoping it may help,
Vanderghast, Access MVP


Michel,
OK, I was right on what I did. I entered thr code in SQL view
with
the
correct names of my tables. I am getting a syntax error in the
JOIN
operation
that I can't figure out. Here is the code: Any ideas?

SELECT [tbl Associate]. [Associate #], [First Name], [Last Name],
[tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data
entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate
number] =
[tbl
associate]. [associate #]
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate. associate #, First Name, Last Name, tbl
certificates. certificate, a.certificate code
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE
certificate
code
=
a.certificate code)));


Thanks,
greg

:

The code is just one query, enter the code in SQL view.

The tables that are not obvious are EmployeeTrainings and
Requirements.

EmployeeTrainings list each training that each employee got, on
pair
by
record, no duplicated pairs.

Requirements is a table that list all the trainings needed to
get
one
certificate, but, again only one (training-certificate pair) per
record,
no
duplicated pairs.

Other tables are just there to convert numbers_id into
meaningful
text
description.


Hoping it may help,
Vanderghast, Access MVP



Michel,

This sounds like it will work, I think I need to set up my
exsiting
tables
so that they match up with the training tables like you said.
I
thought
I
had
done that, but your version seems to be a lot better.

My main question, is where to enter the code you have given
me?
Is
that
in
a
query? Two queries? Where, and how do I enter it? I have never
used
code
that
extensive. Could you please explain the table's you have
listed
so I
make
sure I am on the right track?

Thanks for your help!

:

Wrong table design, I think. I suggest:


Certificates CertificateID CertificateName
1 The Basic one
2 Some other
3 Another certificate




Trainings TrainingID TrainingName
1 TrainingA
2 TrainingB
3 TrainingC
4 TrainingD



Requirements certificateID trainingID
1 1
1 2
1 3
2 1
2 3
3 1
3 2
3 4





Employee EmployeeID EmployeeName
1 Joe
2 Julie
3 John
4 Tom




EmployeeTrainings EmployeeID TrainingID
1 1
1 2
1 3
1 4
2 1
2 4
3 1
3 2
3 3
4 2
4 3
4 4




then

SELECT Employee.EmployeeName, Certificates.CertificateName,
a.certificateID

FROM ((EmployeeTrainings INNER JOIN Requirements AS a ON
EmployeeTrainings.TrainingID = a.trainingID)
INNER JOIN Employee ON EmployeeTrainings.EmployeeID =
Employee.EmployeeID)
INNER JOIN Certificates ON a.certificateID =
Certificates.CertificateID

GROUP BY Employee.EmployeeName, Certificates.CertificateName,
a.certificateID
HAVING (((Count(*))=(SELECT COUNT(*) FROM Requirements WHERE
certificateID=a.certificateID)));


result into:


Query2 EmployeeName CertificateName certificateID
Joe Another certificate 3
Joe Some other 2
Joe The Basic one 1
John Some other 2
 
G

GMac

Michel,

That's what I over looked when I decided to set up this query. The thing is,
the training data table records all training taken in the lab. The associate
might be in a production position which means he has to take the training
required to get the fundamentals certificate (if he/she wants to be put in
the Maintenance Pool). From there, associates are selected to a Maintenance
position. Once in Maintenance, they have to take a placement test
(writen/hands on) if they don't test out they have to start at the
fundamentals training while in the Maintenance Development Program. This is
where duplicate training codes take place. We track the associates with a "P"
for production or "TDP" for the Maintenance Program. Could I get around the
problem if I add this in the query. If so, where?

Thanks,
greg

Michel Walsh said:
Nope, you have to built an index that forbid duplicated pairs.

To build an index on more than a single field, open the table in design
view, open the index window,

- give a name for the index, in the first column,
- type one of the field making the index in the second column
- specify an ordering, if wanted
- in the bottom left, change the Unique from No to Yes

- get to the next line in the grid, but type nothing in the first
column,
- specify another field in the second column


That will create an index forbidding duplicated pairs (of field). Sure, if
your table already have duplicated pair, Access won't let you save the
design. So, be sure you don't have duplicate pairs, first.



The two junctions tables, those I named Requirements and
EmployeeTrainings, MUST NOT have duplicated pairs: after all, a certificate
does not ask you take the a given training twice; neither is it expected to
have an employee completing with success the same training twice



Hoping it may help,
Vanderghast, Access MVP



GMac said:
Thanks Gary,
It worked. One problem I found is that if there is a duplicate value
(which
happens) in the data entry for an associate, then they do not show up in
the
query results.

Would I have to change the count to maybe Dcount?

greg

Gary Walter said:
Open [tbl data entry] in design mode
and see how spelled "training code"

Open [tbl Labs] in design mode
and see how spelled "training code"

adjust to correct spelling in

[tbl data entry].[training code] = a.[training code]


"GMac"wrote:
Ok.......I got the query to work, but there is still a problem. When I
run
the query it is asking for a training code. Why?
And the query results are not right. It is listing all certificates for
each
associate instead of looking at the training codes and seeing if each
associate has met the criteria for each certificate. example
certificate A
needs training codes A,B,C,D to be complete in order for certificate A
to
be
earned. The data entry table lists all training codes completed by each
associate. I think I'm getting closer, but still need help!

Thanks

:

there should be no space on either side of
decimal point...maybe get you closer...

SELECT
[tbl Associate].[Associate #],
[First Name],
[Last Name],
[tbl Certificates].[Certificate],
a.[Certificate code]
FROM
(
(
[tbl data entry]
INNER JOIN
[tbl Labs] AS a
ON
[tbl data entry].[training code] = a.[training code]
)
INNER JOIN
[tbl Associate]
ON
[tbl data entry].[associate number] = [tbl associate].[associate #]
)
INNER JOIN
[tbl certificates]
ON
a.[certificate code] = [tbl certificates].[certificate code]
GROUP BY
[tbl Associate].[associate #],
[ First Name],
[Last Name],
[tbl certificates].certificate,
a.[certificate code]
HAVING
((count(*)) =
(SELECT
COUNT(*)
FROM [tbl labs]
WHERE
[certificate code] = a.[certificate code])));


"GMac" > Michel,

Upon correcting the errors you have listed, I get this:

Invalid use of '.','!', or '( )' in Query Expression [tbl data
entry] .
[training code] = a.[training code] I occured when I entered the
missing )
you had listed. My code looks like this now:
SELECT [tbl Associate]. [Associate #], [First Name], [Last Name],
[tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data
entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate number] =
[tbl
associate]. [associate #])
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate.[associate #],[ First Name], [Last Name], tbl
certificates. certificate, a.[certificate code]
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE
certificate
code
= a.[certificate code])));

Thanks again for all your help, this thing is driving me crazy!
greg



:

A ) is missing before the last INNER JOIN.

The GROUP BY clause need [ ] around the illegal fields name:

GROUP BY tbl Associate.[associate #], [First Name], [Last Name],
tblcertificates.certificate, a.[certificate code]


and also in the WHERE clause of the sub-query in the main HAVING
clause:
a.[certificate code]

.... a good reason to NOT use illegal names for fields (use the
caption
property, if you want names easy to read, automatically displayed
on
user
interface).



Hoping it may help,
Vanderghast, Access MVP


Michel,
OK, I was right on what I did. I entered thr code in SQL view
with
the
correct names of my tables. I am getting a syntax error in the
JOIN
operation
that I can't figure out. Here is the code: Any ideas?

SELECT [tbl Associate]. [Associate #], [First Name], [Last Name],
[tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data
entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate
number] =
[tbl
associate]. [associate #]
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate. associate #, First Name, Last Name, tbl
certificates. certificate, a.certificate code
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE
certificate
code
=
a.certificate code)));


Thanks,
greg

:

The code is just one query, enter the code in SQL view.

The tables that are not obvious are EmployeeTrainings and
Requirements.

EmployeeTrainings list each training that each employee got, on
pair
by
record, no duplicated pairs.

Requirements is a table that list all the trainings needed to
get
one
certificate, but, again only one (training-certificate pair) per
record,
no
duplicated pairs.

Other tables are just there to convert numbers_id into
meaningful
text
description.


Hoping it may help,
Vanderghast, Access MVP



Michel,

This sounds like it will work, I think I need to set up my
exsiting
tables
so that they match up with the training tables like you said.
I
thought
I
had
done that, but your version seems to be a lot better.

My main question, is where to enter the code you have given
me?
Is
that
in
a
query? Two queries? Where, and how do I enter it? I have never
used
code
that
extensive. Could you please explain the table's you have
listed
so I
make
sure I am on the right track?

Thanks for your help!

:

Wrong table design, I think. I suggest:


Certificates CertificateID CertificateName
1 The Basic one
2 Some other
3 Another certificate




Trainings TrainingID TrainingName
1 TrainingA
2 TrainingB
3 TrainingC
4 TrainingD



Requirements certificateID trainingID
1 1
 
M

Michel Walsh

You can use a query that pumps out only the records (employee-training) that
are relevant, without duplicated, and use that query, rather than the
original table.


Hoping it may help,
Vanderghast, Access MVP


GMac said:
Michel,

That's what I over looked when I decided to set up this query. The thing
is,
the training data table records all training taken in the lab. The
associate
might be in a production position which means he has to take the training
required to get the fundamentals certificate (if he/she wants to be put in
the Maintenance Pool). From there, associates are selected to a
Maintenance
position. Once in Maintenance, they have to take a placement test
(writen/hands on) if they don't test out they have to start at the
fundamentals training while in the Maintenance Development Program. This
is
where duplicate training codes take place. We track the associates with a
"P"
for production or "TDP" for the Maintenance Program. Could I get around
the
problem if I add this in the query. If so, where?

Thanks,
greg

Michel Walsh said:
Nope, you have to built an index that forbid duplicated pairs.

To build an index on more than a single field, open the table in design
view, open the index window,

- give a name for the index, in the first column,
- type one of the field making the index in the second column
- specify an ordering, if wanted
- in the bottom left, change the Unique from No to Yes

- get to the next line in the grid, but type nothing in the first
column,
- specify another field in the second column


That will create an index forbidding duplicated pairs (of field). Sure,
if
your table already have duplicated pair, Access won't let you save the
design. So, be sure you don't have duplicate pairs, first.



The two junctions tables, those I named Requirements and
EmployeeTrainings, MUST NOT have duplicated pairs: after all, a
certificate
does not ask you take the a given training twice; neither is it expected
to
have an employee completing with success the same training twice



Hoping it may help,
Vanderghast, Access MVP



GMac said:
Thanks Gary,
It worked. One problem I found is that if there is a duplicate value
(which
happens) in the data entry for an associate, then they do not show up
in
the
query results.

Would I have to change the count to maybe Dcount?

greg

:

Open [tbl data entry] in design mode
and see how spelled "training code"

Open [tbl Labs] in design mode
and see how spelled "training code"

adjust to correct spelling in

[tbl data entry].[training code] = a.[training code]


"GMac"wrote:
Ok.......I got the query to work, but there is still a problem. When
I
run
the query it is asking for a training code. Why?
And the query results are not right. It is listing all certificates
for
each
associate instead of looking at the training codes and seeing if
each
associate has met the criteria for each certificate. example
certificate A
needs training codes A,B,C,D to be complete in order for certificate
A
to
be
earned. The data entry table lists all training codes completed by
each
associate. I think I'm getting closer, but still need help!

Thanks

:

there should be no space on either side of
decimal point...maybe get you closer...

SELECT
[tbl Associate].[Associate #],
[First Name],
[Last Name],
[tbl Certificates].[Certificate],
a.[Certificate code]
FROM
(
(
[tbl data entry]
INNER JOIN
[tbl Labs] AS a
ON
[tbl data entry].[training code] = a.[training code]
)
INNER JOIN
[tbl Associate]
ON
[tbl data entry].[associate number] = [tbl associate].[associate #]
)
INNER JOIN
[tbl certificates]
ON
a.[certificate code] = [tbl certificates].[certificate code]
GROUP BY
[tbl Associate].[associate #],
[ First Name],
[Last Name],
[tbl certificates].certificate,
a.[certificate code]
HAVING
((count(*)) =
(SELECT
COUNT(*)
FROM [tbl labs]
WHERE
[certificate code] = a.[certificate code])));


"GMac" > Michel,

Upon correcting the errors you have listed, I get this:

Invalid use of '.','!', or '( )' in Query Expression [tbl data
entry] .
[training code] = a.[training code] I occured when I entered the
missing )
you had listed. My code looks like this now:
SELECT [tbl Associate]. [Associate #], [First Name], [Last Name],
[tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data
entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate
number] =
[tbl
associate]. [associate #])
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate.[associate #],[ First Name], [Last Name],
tbl
certificates. certificate, a.[certificate code]
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE
certificate
code
= a.[certificate code])));

Thanks again for all your help, this thing is driving me crazy!
greg



:

A ) is missing before the last INNER JOIN.

The GROUP BY clause need [ ] around the illegal fields name:

GROUP BY tbl Associate.[associate #], [First Name], [Last Name],
tblcertificates.certificate, a.[certificate code]


and also in the WHERE clause of the sub-query in the main HAVING
clause:
a.[certificate code]

.... a good reason to NOT use illegal names for fields (use the
caption
property, if you want names easy to read, automatically
displayed
on
user
interface).



Hoping it may help,
Vanderghast, Access MVP


Michel,
OK, I was right on what I did. I entered thr code in SQL view
with
the
correct names of my tables. I am getting a syntax error in the
JOIN
operation
that I can't figure out. Here is the code: Any ideas?

SELECT [tbl Associate]. [Associate #], [First Name], [Last
Name],
[tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl
data
entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate
number] =
[tbl
associate]. [associate #]
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate. associate #, First Name, Last Name,
tbl
certificates. certificate, a.certificate code
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE
certificate
code
=
a.certificate code)));


Thanks,
greg

:

The code is just one query, enter the code in SQL view.

The tables that are not obvious are EmployeeTrainings and
Requirements.

EmployeeTrainings list each training that each employee got,
on
pair
by
record, no duplicated pairs.

Requirements is a table that list all the trainings needed to
get
one
certificate, but, again only one (training-certificate pair)
per
record,
no
duplicated pairs.

Other tables are just there to convert numbers_id into
meaningful
text
description.


Hoping it may help,
Vanderghast, Access MVP



Michel,

This sounds like it will work, I think I need to set up my
exsiting
tables
so that they match up with the training tables like you
said.
I
thought
I
had
done that, but your version seems to be a lot better.

My main question, is where to enter the code you have given
me?
Is
that
in
a
query? Two queries? Where, and how do I enter it? I have
never
used
code
that
extensive. Could you please explain the table's you have
listed
so I
make
sure I am on the right track?

Thanks for your help!

:

Wrong table design, I think. I suggest:


Certificates CertificateID CertificateName
1 The Basic one
2 Some other
3 Another certificate




Trainings TrainingID TrainingName
1 TrainingA
2 TrainingB
3 TrainingC
4 TrainingD



Requirements certificateID trainingID
1 1
 
G

GMac

Thank You!

greg

Michel Walsh said:
You can use a query that pumps out only the records (employee-training) that
are relevant, without duplicated, and use that query, rather than the
original table.


Hoping it may help,
Vanderghast, Access MVP


GMac said:
Michel,

That's what I over looked when I decided to set up this query. The thing
is,
the training data table records all training taken in the lab. The
associate
might be in a production position which means he has to take the training
required to get the fundamentals certificate (if he/she wants to be put in
the Maintenance Pool). From there, associates are selected to a
Maintenance
position. Once in Maintenance, they have to take a placement test
(writen/hands on) if they don't test out they have to start at the
fundamentals training while in the Maintenance Development Program. This
is
where duplicate training codes take place. We track the associates with a
"P"
for production or "TDP" for the Maintenance Program. Could I get around
the
problem if I add this in the query. If so, where?

Thanks,
greg

Michel Walsh said:
Nope, you have to built an index that forbid duplicated pairs.

To build an index on more than a single field, open the table in design
view, open the index window,

- give a name for the index, in the first column,
- type one of the field making the index in the second column
- specify an ordering, if wanted
- in the bottom left, change the Unique from No to Yes

- get to the next line in the grid, but type nothing in the first
column,
- specify another field in the second column


That will create an index forbidding duplicated pairs (of field). Sure,
if
your table already have duplicated pair, Access won't let you save the
design. So, be sure you don't have duplicate pairs, first.



The two junctions tables, those I named Requirements and
EmployeeTrainings, MUST NOT have duplicated pairs: after all, a
certificate
does not ask you take the a given training twice; neither is it expected
to
have an employee completing with success the same training twice



Hoping it may help,
Vanderghast, Access MVP



Thanks Gary,
It worked. One problem I found is that if there is a duplicate value
(which
happens) in the data entry for an associate, then they do not show up
in
the
query results.

Would I have to change the count to maybe Dcount?

greg

:

Open [tbl data entry] in design mode
and see how spelled "training code"

Open [tbl Labs] in design mode
and see how spelled "training code"

adjust to correct spelling in

[tbl data entry].[training code] = a.[training code]


"GMac"wrote:
Ok.......I got the query to work, but there is still a problem. When
I
run
the query it is asking for a training code. Why?
And the query results are not right. It is listing all certificates
for
each
associate instead of looking at the training codes and seeing if
each
associate has met the criteria for each certificate. example
certificate A
needs training codes A,B,C,D to be complete in order for certificate
A
to
be
earned. The data entry table lists all training codes completed by
each
associate. I think I'm getting closer, but still need help!

Thanks

:

there should be no space on either side of
decimal point...maybe get you closer...

SELECT
[tbl Associate].[Associate #],
[First Name],
[Last Name],
[tbl Certificates].[Certificate],
a.[Certificate code]
FROM
(
(
[tbl data entry]
INNER JOIN
[tbl Labs] AS a
ON
[tbl data entry].[training code] = a.[training code]
)
INNER JOIN
[tbl Associate]
ON
[tbl data entry].[associate number] = [tbl associate].[associate #]
)
INNER JOIN
[tbl certificates]
ON
a.[certificate code] = [tbl certificates].[certificate code]
GROUP BY
[tbl Associate].[associate #],
[ First Name],
[Last Name],
[tbl certificates].certificate,
a.[certificate code]
HAVING
((count(*)) =
(SELECT
COUNT(*)
FROM [tbl labs]
WHERE
[certificate code] = a.[certificate code])));


"GMac" > Michel,

Upon correcting the errors you have listed, I get this:

Invalid use of '.','!', or '( )' in Query Expression [tbl data
entry] .
[training code] = a.[training code] I occured when I entered the
missing )
you had listed. My code looks like this now:
SELECT [tbl Associate]. [Associate #], [First Name], [Last Name],
[tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl data
entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate
number] =
[tbl
associate]. [associate #])
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate.[associate #],[ First Name], [Last Name],
tbl
certificates. certificate, a.[certificate code]
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE
certificate
code
= a.[certificate code])));

Thanks again for all your help, this thing is driving me crazy!
greg



:

A ) is missing before the last INNER JOIN.

The GROUP BY clause need [ ] around the illegal fields name:

GROUP BY tbl Associate.[associate #], [First Name], [Last Name],
tblcertificates.certificate, a.[certificate code]


and also in the WHERE clause of the sub-query in the main HAVING
clause:
a.[certificate code]

.... a good reason to NOT use illegal names for fields (use the
caption
property, if you want names easy to read, automatically
displayed
on
user
interface).



Hoping it may help,
Vanderghast, Access MVP


Michel,
OK, I was right on what I did. I entered thr code in SQL view
with
the
correct names of my tables. I am getting a syntax error in the
JOIN
operation
that I can't figure out. Here is the code: Any ideas?

SELECT [tbl Associate]. [Associate #], [First Name], [Last
Name],
[tbl
Certificates]. [Certificate], a.[Certificate code]
FROM (([tbl data entry] INNER JOIN [tbl Labs] AS a ON [tbl
data
entry].
[training code] = a.[training code])
INNER JOIN [tbl Associate] ON [tbl data entry]. [associate
number] =
[tbl
associate]. [associate #]
INNER JOIN [tbl certificates] ON a.[certificate code] = [tbl
certificates].[certificate code]
GROUP BY tbl Associate. associate #, First Name, Last Name,
tbl
certificates. certificate, a.certificate code
HAVING ((count(*)) = (SELECT COUNT(*) FROM tbl labs WHERE
certificate
code
=
a.certificate code)));


Thanks,
greg

:

The code is just one query, enter the code in SQL view.

The tables that are not obvious are EmployeeTrainings and
Requirements.

EmployeeTrainings list each training that each employee got,
on
pair
by
record, no duplicated pairs.

Requirements is a table that list all the trainings needed to
get
one
certificate, but, again only one (training-certificate pair)
per
record,
no
duplicated pairs.

Other tables are just there to convert numbers_id into
meaningful
text
description.


Hoping it may help,
Vanderghast, Access MVP



news:[email protected]...
 

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

Similar Threads

Need help with Queries 4
Publisher is filling blank lines with data 2
A Nigtmare! 0
Insert Index into a Table 1
Where to start 10
HELP! 3
Need help finding old, outdated contacts in Outlook 365 on my PC 0
Bruce M 19

Top