Count in a query

G

Guest

Hi all,

I have a query with doubles and I want to know how many times the Record
appears in this query. How do I do that for every row ?

It's a combination of 2 tables that share some common ground... so it shows
some records several times. How to count them...
I know that in excel it would be
=CountIf(A$2:A$100;A3)
 
G

Guest

Okay, might be a ridiculously dumb question but where do I put the expression
and how do I fill it out if I am looking to count the Reoccurring value in
field [ID] for Query [Test List]

I tried but get #error
 
D

Duane Hookom

You have to provide some sample records or at least significant field and
table names. In order to number your records, you must have a field that
identifies which record would be the 1st value and which is the 2nd.

SELECT *, (SELECT Count(*) FROM tblEmployees E WHERE E.Dept =
tblEmployees.Dept And E.HireDate <=tblEmployees.HireDate) as DeptRank
FROM tblEmployees;

The HireDate is what determines the rank within the department.

--
Duane Hookom
MS Access MVP
--

Ben said:
Okay, might be a ridiculously dumb question but where do I put the
expression
and how do I fill it out if I am looking to count the Reoccurring value in
field [ID] for Query [Test List]

I tried but get #error


--
Novice


Robert_DubYa said:
Try using the dcount function in your query.
 
G

Guest

Duane,
Thanks for your help but I don't understand it...

What I have is Query 'TestList' which shows all records in table 'Doctors'
and all records in table 'Calls' (as calls made to doctors)
This list now shows all doctors once without a call assigned to it and once
with a call assigned to it so some doctorID's appear more than once.
What I want is to count how many times every doctor ID appears in the query.
As I have over 200000 records in this query, I need to filter this fast and
with that little formula that I seek, I would have a fast and simple solution
to a long story that frustrates all of my users.
And this formula would then come in a new column in my query.

Sorry if this doesn't make sense.



--
Novice


Duane Hookom said:
You have to provide some sample records or at least significant field and
table names. In order to number your records, you must have a field that
identifies which record would be the 1st value and which is the 2nd.

SELECT *, (SELECT Count(*) FROM tblEmployees E WHERE E.Dept =
tblEmployees.Dept And E.HireDate <=tblEmployees.HireDate) as DeptRank
FROM tblEmployees;

The HireDate is what determines the rank within the department.

--
Duane Hookom
MS Access MVP
--

Ben said:
Okay, might be a ridiculously dumb question but where do I put the
expression
and how do I fill it out if I am looking to count the Reoccurring value in
field [ID] for Query [Test List]

I tried but get #error


--
Novice


Robert_DubYa said:
Try using the dcount function in your query.

:

Hi all,

I have a query with doubles and I want to know how many times the
Record
appears in this query. How do I do that for every row ?

It's a combination of 2 tables that share some common ground... so it
shows
some records several times. How to count them...
I know that in excel it would be
=CountIf(A$2:A$100;A3)
 
D

Duane Hookom

How about you give us a few sample records that accurately describe what you
have? Then provide us with how these should display and why.

Are you displaying all of this eventually in a report or form?

--
Duane Hookom
MS Access MVP
--

Ben said:
Duane,
Thanks for your help but I don't understand it...

What I have is Query 'TestList' which shows all records in table 'Doctors'
and all records in table 'Calls' (as calls made to doctors)
This list now shows all doctors once without a call assigned to it and
once
with a call assigned to it so some doctorID's appear more than once.
What I want is to count how many times every doctor ID appears in the
query.
As I have over 200000 records in this query, I need to filter this fast
and
with that little formula that I seek, I would have a fast and simple
solution
to a long story that frustrates all of my users.
And this formula would then come in a new column in my query.

Sorry if this doesn't make sense.



--
Novice


Duane Hookom said:
You have to provide some sample records or at least significant field and
table names. In order to number your records, you must have a field that
identifies which record would be the 1st value and which is the 2nd.

SELECT *, (SELECT Count(*) FROM tblEmployees E WHERE E.Dept =
tblEmployees.Dept And E.HireDate <=tblEmployees.HireDate) as DeptRank
FROM tblEmployees;

The HireDate is what determines the rank within the department.

--
Duane Hookom
MS Access MVP
--

Ben said:
Okay, might be a ridiculously dumb question but where do I put the
expression
and how do I fill it out if I am looking to count the Reoccurring value
in
field [ID] for Query [Test List]

I tried but get #error


--
Novice


:

Try using the dcount function in your query.

:

Hi all,

I have a query with doubles and I want to know how many times the
Record
appears in this query. How do I do that for every row ?

It's a combination of 2 tables that share some common ground... so
it
shows
some records several times. How to count them...
I know that in excel it would be
=CountIf(A$2:A$100;A3)
 
G

Guest

ID Name Project Result COUNT
17 James Test25 Done 2
19 George 2
25 Ben Test25 Cancelled 1
17 James 2
19 George Test25 Done 2
21 Louis 1
07 Ellen 1

ID - Name - Project - Result are taken from tables and exist. Count is what
I look for. It gives a number for the amount of times an ID (name) appears in
the query.

I am going to display them in a continuous form where I will filter them
with VBA on click. I just need to get this count so I can remove all the ones
that say more than 1 after. To display all names that haven't been called yet
for the specific project.


--
Novice


Duane Hookom said:
How about you give us a few sample records that accurately describe what you
have? Then provide us with how these should display and why.

Are you displaying all of this eventually in a report or form?

--
Duane Hookom
MS Access MVP
--

Ben said:
Duane,
Thanks for your help but I don't understand it...

What I have is Query 'TestList' which shows all records in table 'Doctors'
and all records in table 'Calls' (as calls made to doctors)
This list now shows all doctors once without a call assigned to it and
once
with a call assigned to it so some doctorID's appear more than once.
What I want is to count how many times every doctor ID appears in the
query.
As I have over 200000 records in this query, I need to filter this fast
and
with that little formula that I seek, I would have a fast and simple
solution
to a long story that frustrates all of my users.
And this formula would then come in a new column in my query.

Sorry if this doesn't make sense.



--
Novice


Duane Hookom said:
You have to provide some sample records or at least significant field and
table names. In order to number your records, you must have a field that
identifies which record would be the 1st value and which is the 2nd.

SELECT *, (SELECT Count(*) FROM tblEmployees E WHERE E.Dept =
tblEmployees.Dept And E.HireDate <=tblEmployees.HireDate) as DeptRank
FROM tblEmployees;

The HireDate is what determines the rank within the department.

--
Duane Hookom
MS Access MVP
--

Okay, might be a ridiculously dumb question but where do I put the
expression
and how do I fill it out if I am looking to count the Reoccurring value
in
field [ID] for Query [Test List]

I tried but get #error


--
Novice


:

Try using the dcount function in your query.

:

Hi all,

I have a query with doubles and I want to know how many times the
Record
appears in this query. How do I do that for every row ?

It's a combination of 2 tables that share some common ground... so
it
shows
some records several times. How to count them...
I know that in excel it would be
=CountIf(A$2:A$100;A3)
 
D

Duane Hookom

Try
SELECT [the query].*,
(SELECT Count(*)
FROM [the query] q
WHERE q.[Name] = [the query].[Name] ) as TheCount
FROM [the query];

BTW: I don't care for field/column names that are properties, functions, or
sql aggregates (Name, Count)
--
Duane Hookom
MS Access MVP
--

Ben said:
ID Name Project Result COUNT
17 James Test25 Done 2
19 George 2
25 Ben Test25 Cancelled 1
17 James 2
19 George Test25 Done 2
21 Louis 1
07 Ellen 1

ID - Name - Project - Result are taken from tables and exist. Count is
what
I look for. It gives a number for the amount of times an ID (name) appears
in
the query.

I am going to display them in a continuous form where I will filter them
with VBA on click. I just need to get this count so I can remove all the
ones
that say more than 1 after. To display all names that haven't been called
yet
for the specific project.


--
Novice


Duane Hookom said:
How about you give us a few sample records that accurately describe what
you
have? Then provide us with how these should display and why.

Are you displaying all of this eventually in a report or form?

--
Duane Hookom
MS Access MVP
--

Ben said:
Duane,
Thanks for your help but I don't understand it...

What I have is Query 'TestList' which shows all records in table
'Doctors'
and all records in table 'Calls' (as calls made to doctors)
This list now shows all doctors once without a call assigned to it and
once
with a call assigned to it so some doctorID's appear more than once.
What I want is to count how many times every doctor ID appears in the
query.
As I have over 200000 records in this query, I need to filter this fast
and
with that little formula that I seek, I would have a fast and simple
solution
to a long story that frustrates all of my users.
And this formula would then come in a new column in my query.

Sorry if this doesn't make sense.



--
Novice


:

You have to provide some sample records or at least significant field
and
table names. In order to number your records, you must have a field
that
identifies which record would be the 1st value and which is the 2nd.

SELECT *, (SELECT Count(*) FROM tblEmployees E WHERE E.Dept =
tblEmployees.Dept And E.HireDate <=tblEmployees.HireDate) as DeptRank
FROM tblEmployees;

The HireDate is what determines the rank within the department.

--
Duane Hookom
MS Access MVP
--

Okay, might be a ridiculously dumb question but where do I put the
expression
and how do I fill it out if I am looking to count the Reoccurring
value
in
field [ID] for Query [Test List]

I tried but get #error


--
Novice


:

Try using the dcount function in your query.

:

Hi all,

I have a query with doubles and I want to know how many times the
Record
appears in this query. How do I do that for every row ?

It's a combination of 2 tables that share some common ground...
so
it
shows
some records several times. How to count them...
I know that in excel it would be
=CountIf(A$2:A$100;A3)
 
G

Guest

And where do I put this ? Sorry for my incompetence

SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];





--
Novice


Duane Hookom said:
Try
SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];

BTW: I don't care for field/column names that are properties, functions, or
sql aggregates (Name, Count)
--
Duane Hookom
MS Access MVP
--

Ben said:
ID Name Project Result COUNT
17 James Test25 Done 2
19 George 2
25 Ben Test25 Cancelled 1
17 James 2
19 George Test25 Done 2
21 Louis 1
07 Ellen 1

ID - Name - Project - Result are taken from tables and exist. Count is
what
I look for. It gives a number for the amount of times an ID (name) appears
in
the query.

I am going to display them in a continuous form where I will filter them
with VBA on click. I just need to get this count so I can remove all the
ones
that say more than 1 after. To display all names that haven't been called
yet
for the specific project.


--
Novice


Duane Hookom said:
How about you give us a few sample records that accurately describe what
you
have? Then provide us with how these should display and why.

Are you displaying all of this eventually in a report or form?

--
Duane Hookom
MS Access MVP
--

Duane,
Thanks for your help but I don't understand it...

What I have is Query 'TestList' which shows all records in table
'Doctors'
and all records in table 'Calls' (as calls made to doctors)
This list now shows all doctors once without a call assigned to it and
once
with a call assigned to it so some doctorID's appear more than once.
What I want is to count how many times every doctor ID appears in the
query.
As I have over 200000 records in this query, I need to filter this fast
and
with that little formula that I seek, I would have a fast and simple
solution
to a long story that frustrates all of my users.
And this formula would then come in a new column in my query.

Sorry if this doesn't make sense.



--
Novice


:

You have to provide some sample records or at least significant field
and
table names. In order to number your records, you must have a field
that
identifies which record would be the 1st value and which is the 2nd.

SELECT *, (SELECT Count(*) FROM tblEmployees E WHERE E.Dept =
tblEmployees.Dept And E.HireDate <=tblEmployees.HireDate) as DeptRank
FROM tblEmployees;

The HireDate is what determines the rank within the department.

--
Duane Hookom
MS Access MVP
--

Okay, might be a ridiculously dumb question but where do I put the
expression
and how do I fill it out if I am looking to count the Reoccurring
value
in
field [ID] for Query [Test List]

I tried but get #error


--
Novice


:

Try using the dcount function in your query.

:

Hi all,

I have a query with doubles and I want to know how many times the
Record
appears in this query. How do I do that for every row ?

It's a combination of 2 tables that share some common ground...
so
it
shows
some records several times. How to count them...
I know that in excel it would be
=CountIf(A$2:A$100;A3)
 
D

Duane Hookom

You would enter the select statement into the SQL view of a query. Make sure
you use your table and field names.

--
Duane Hookom
MS Access MVP
--

Ben said:
And where do I put this ? Sorry for my incompetence

SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];





--
Novice


Duane Hookom said:
Try
SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];

BTW: I don't care for field/column names that are properties, functions,
or
sql aggregates (Name, Count)
--
Duane Hookom
MS Access MVP
--

Ben said:
ID Name Project Result COUNT
17 James Test25 Done 2
19 George 2
25 Ben Test25 Cancelled 1
17 James 2
19 George Test25 Done 2
21 Louis 1
07 Ellen 1

ID - Name - Project - Result are taken from tables and exist. Count is
what
I look for. It gives a number for the amount of times an ID (name)
appears
in
the query.

I am going to display them in a continuous form where I will filter
them
with VBA on click. I just need to get this count so I can remove all
the
ones
that say more than 1 after. To display all names that haven't been
called
yet
for the specific project.


--
Novice


:

How about you give us a few sample records that accurately describe
what
you
have? Then provide us with how these should display and why.

Are you displaying all of this eventually in a report or form?

--
Duane Hookom
MS Access MVP
--

Duane,
Thanks for your help but I don't understand it...

What I have is Query 'TestList' which shows all records in table
'Doctors'
and all records in table 'Calls' (as calls made to doctors)
This list now shows all doctors once without a call assigned to it
and
once
with a call assigned to it so some doctorID's appear more than once.
What I want is to count how many times every doctor ID appears in
the
query.
As I have over 200000 records in this query, I need to filter this
fast
and
with that little formula that I seek, I would have a fast and simple
solution
to a long story that frustrates all of my users.
And this formula would then come in a new column in my query.

Sorry if this doesn't make sense.



--
Novice


:

You have to provide some sample records or at least significant
field
and
table names. In order to number your records, you must have a field
that
identifies which record would be the 1st value and which is the
2nd.

SELECT *, (SELECT Count(*) FROM tblEmployees E WHERE E.Dept =
tblEmployees.Dept And E.HireDate <=tblEmployees.HireDate) as
DeptRank
FROM tblEmployees;

The HireDate is what determines the rank within the department.

--
Duane Hookom
MS Access MVP
--

Okay, might be a ridiculously dumb question but where do I put
the
expression
and how do I fill it out if I am looking to count the Reoccurring
value
in
field [ID] for Query [Test List]

I tried but get #error


--
Novice


:

Try using the dcount function in your query.

:

Hi all,

I have a query with doubles and I want to know how many times
the
Record
appears in this query. How do I do that for every row ?

It's a combination of 2 tables that share some common
ground...
so
it
shows
some records several times. How to count them...
I know that in excel it would be
=CountIf(A$2:A$100;A3)
 
G

Guest

I applied it to my existing query sql but I must be doing something wrong
(circular referens error message shown).
Here is my SQL for Query [Test List]

SELECT L.ID, L.[Country ID], L.Region, L.[Dokter info ID], L.[Name
Practice/Hospital], L.[First name], L.[Last name], L.Title, L.[Male/Female],
L.[Language ID], L.specialisme, L.[Country number], L.Phonenumber,
L.Faxnumber, Called.Practician, Called.[Project ID], [Practician] &
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS Uttryck1, [ID] &
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS Uttryck2,
IIf([Uttryck1]=[Uttryck2],"Don't","Show") AS Uttryck3, (SELECT Count(*) FROM
[Test List] q WHERE q.[ID] = L.[ID] ) AS TheCount
FROM [lÄKARE LIST] AS L LEFT JOIN Called ON L.ID = Called.Practician
WHERE (((Called.[Project
ID])=[Forms]![SelectProjectforListtocall]![Kombinationsruta0] Or
(Called.[Project ID]) Is Null));


(in case you would wonder:
[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
this is an external factor to eliminate all calls that are not related to
this project. It will only keep the ID's of doctors that have been called for
the chosen project and the complete list of doctors. now I want to remove the
doubles in the same query by counting the recurring ID's)



--
Novice


Duane Hookom said:
You would enter the select statement into the SQL view of a query. Make sure
you use your table and field names.

--
Duane Hookom
MS Access MVP
--

Ben said:
And where do I put this ? Sorry for my incompetence

SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];





--
Novice


Duane Hookom said:
Try
SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];

BTW: I don't care for field/column names that are properties, functions,
or
sql aggregates (Name, Count)
--
Duane Hookom
MS Access MVP
--

ID Name Project Result COUNT
17 James Test25 Done 2
19 George 2
25 Ben Test25 Cancelled 1
17 James 2
19 George Test25 Done 2
21 Louis 1
07 Ellen 1

ID - Name - Project - Result are taken from tables and exist. Count is
what
I look for. It gives a number for the amount of times an ID (name)
appears
in
the query.

I am going to display them in a continuous form where I will filter
them
with VBA on click. I just need to get this count so I can remove all
the
ones
that say more than 1 after. To display all names that haven't been
called
yet
for the specific project.


--
Novice


:

How about you give us a few sample records that accurately describe
what
you
have? Then provide us with how these should display and why.

Are you displaying all of this eventually in a report or form?

--
Duane Hookom
MS Access MVP
--

Duane,
Thanks for your help but I don't understand it...

What I have is Query 'TestList' which shows all records in table
'Doctors'
and all records in table 'Calls' (as calls made to doctors)
This list now shows all doctors once without a call assigned to it
and
once
with a call assigned to it so some doctorID's appear more than once.
What I want is to count how many times every doctor ID appears in
the
query.
As I have over 200000 records in this query, I need to filter this
fast
and
with that little formula that I seek, I would have a fast and simple
solution
to a long story that frustrates all of my users.
And this formula would then come in a new column in my query.

Sorry if this doesn't make sense.



--
Novice


:

You have to provide some sample records or at least significant
field
and
table names. In order to number your records, you must have a field
that
identifies which record would be the 1st value and which is the
2nd.

SELECT *, (SELECT Count(*) FROM tblEmployees E WHERE E.Dept =
tblEmployees.Dept And E.HireDate <=tblEmployees.HireDate) as
DeptRank
FROM tblEmployees;

The HireDate is what determines the rank within the department.

--
Duane Hookom
MS Access MVP
--

Okay, might be a ridiculously dumb question but where do I put
the
expression
and how do I fill it out if I am looking to count the Reoccurring
value
in
field [ID] for Query [Test List]

I tried but get #error


--
Novice


:

Try using the dcount function in your query.

:

Hi all,

I have a query with doubles and I want to know how many times
the
Record
appears in this query. How do I do that for every row ?

It's a combination of 2 tables that share some common
ground...
so
it
shows
some records several times. How to count them...
I know that in excel it would be
=CountIf(A$2:A$100;A3)
 
D

Duane Hookom

I think the issue is because you create a column named Uttryck2 and then use
it in another expression. I avoid this at all cost.

--
Duane Hookom
MS Access MVP
--

Ben said:
I applied it to my existing query sql but I must be doing something wrong
(circular referens error message shown).
Here is my SQL for Query [Test List]

SELECT L.ID, L.[Country ID], L.Region, L.[Dokter info ID], L.[Name
Practice/Hospital], L.[First name], L.[Last name], L.Title,
L.[Male/Female],
L.[Language ID], L.specialisme, L.[Country number], L.Phonenumber,
L.Faxnumber, Called.Practician, Called.[Project ID], [Practician] &
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS Uttryck1, [ID]
&
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS Uttryck2,
IIf([Uttryck1]=[Uttryck2],"Don't","Show") AS Uttryck3, (SELECT Count(*)
FROM
[Test List] q WHERE q.[ID] = L.[ID] ) AS TheCount
FROM [lÄKARE LIST] AS L LEFT JOIN Called ON L.ID = Called.Practician
WHERE (((Called.[Project
ID])=[Forms]![SelectProjectforListtocall]![Kombinationsruta0] Or
(Called.[Project ID]) Is Null));


(in case you would wonder:
[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
this is an external factor to eliminate all calls that are not related to
this project. It will only keep the ID's of doctors that have been called
for
the chosen project and the complete list of doctors. now I want to remove
the
doubles in the same query by counting the recurring ID's)



--
Novice


Duane Hookom said:
You would enter the select statement into the SQL view of a query. Make
sure
you use your table and field names.

--
Duane Hookom
MS Access MVP
--

Ben said:
And where do I put this ? Sorry for my incompetence


SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];





--
Novice


:

Try
SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];

BTW: I don't care for field/column names that are properties,
functions,
or
sql aggregates (Name, Count)
--
Duane Hookom
MS Access MVP
--

ID Name Project Result COUNT
17 James Test25 Done 2
19 George 2
25 Ben Test25 Cancelled 1
17 James 2
19 George Test25 Done 2
21 Louis 1
07 Ellen 1

ID - Name - Project - Result are taken from tables and exist. Count
is
what
I look for. It gives a number for the amount of times an ID (name)
appears
in
the query.

I am going to display them in a continuous form where I will filter
them
with VBA on click. I just need to get this count so I can remove all
the
ones
that say more than 1 after. To display all names that haven't been
called
yet
for the specific project.


--
Novice


:

How about you give us a few sample records that accurately describe
what
you
have? Then provide us with how these should display and why.

Are you displaying all of this eventually in a report or form?

--
Duane Hookom
MS Access MVP
--

Duane,
Thanks for your help but I don't understand it...

What I have is Query 'TestList' which shows all records in table
'Doctors'
and all records in table 'Calls' (as calls made to doctors)
This list now shows all doctors once without a call assigned to
it
and
once
with a call assigned to it so some doctorID's appear more than
once.
What I want is to count how many times every doctor ID appears in
the
query.
As I have over 200000 records in this query, I need to filter
this
fast
and
with that little formula that I seek, I would have a fast and
simple
solution
to a long story that frustrates all of my users.
And this formula would then come in a new column in my query.

Sorry if this doesn't make sense.



--
Novice


:

You have to provide some sample records or at least significant
field
and
table names. In order to number your records, you must have a
field
that
identifies which record would be the 1st value and which is the
2nd.

SELECT *, (SELECT Count(*) FROM tblEmployees E WHERE E.Dept =
tblEmployees.Dept And E.HireDate <=tblEmployees.HireDate) as
DeptRank
FROM tblEmployees;

The HireDate is what determines the rank within the department.

--
Duane Hookom
MS Access MVP
--

Okay, might be a ridiculously dumb question but where do I put
the
expression
and how do I fill it out if I am looking to count the
Reoccurring
value
in
field [ID] for Query [Test List]

I tried but get #error


--
Novice


:

Try using the dcount function in your query.

:

Hi all,

I have a query with doubles and I want to know how many
times
the
Record
appears in this query. How do I do that for every row ?

It's a combination of 2 tables that share some common
ground...
so
it
shows
some records several times. How to count them...
I know that in excel it would be
=CountIf(A$2:A$100;A3)
 
G

Guest

Thanks for being so patient with me.

Well, that doesn't seem to be it... Sorry, I should have written the full
error message. It says " Circular reference caused by 'Test List' "

Isn't there something like dcount that can do like this...
Count(all records in Column [ID], from query [Test List], where the [ID]
from current record is equal)
all in query [test list]




--
Novice


Duane Hookom said:
I think the issue is because you create a column named Uttryck2 and then use
it in another expression. I avoid this at all cost.

--
Duane Hookom
MS Access MVP
--

Ben said:
I applied it to my existing query sql but I must be doing something wrong
(circular referens error message shown).
Here is my SQL for Query [Test List]

SELECT L.ID, L.[Country ID], L.Region, L.[Dokter info ID], L.[Name
Practice/Hospital], L.[First name], L.[Last name], L.Title,
L.[Male/Female],
L.[Language ID], L.specialisme, L.[Country number], L.Phonenumber,
L.Faxnumber, Called.Practician, Called.[Project ID], [Practician] &
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS Uttryck1, [ID]
&
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS Uttryck2,
IIf([Uttryck1]=[Uttryck2],"Don't","Show") AS Uttryck3, (SELECT Count(*)
FROM
[Test List] q WHERE q.[ID] = L.[ID] ) AS TheCount
FROM [lÄKARE LIST] AS L LEFT JOIN Called ON L.ID = Called.Practician
WHERE (((Called.[Project
ID])=[Forms]![SelectProjectforListtocall]![Kombinationsruta0] Or
(Called.[Project ID]) Is Null));


(in case you would wonder:
[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
this is an external factor to eliminate all calls that are not related to
this project. It will only keep the ID's of doctors that have been called
for
the chosen project and the complete list of doctors. now I want to remove
the
doubles in the same query by counting the recurring ID's)



--
Novice


Duane Hookom said:
You would enter the select statement into the SQL view of a query. Make
sure
you use your table and field names.

--
Duane Hookom
MS Access MVP
--

And where do I put this ? Sorry for my incompetence


SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];





--
Novice


:

Try
SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];

BTW: I don't care for field/column names that are properties,
functions,
or
sql aggregates (Name, Count)
--
Duane Hookom
MS Access MVP
--

ID Name Project Result COUNT
17 James Test25 Done 2
19 George 2
25 Ben Test25 Cancelled 1
17 James 2
19 George Test25 Done 2
21 Louis 1
07 Ellen 1

ID - Name - Project - Result are taken from tables and exist. Count
is
what
I look for. It gives a number for the amount of times an ID (name)
appears
in
the query.

I am going to display them in a continuous form where I will filter
them
with VBA on click. I just need to get this count so I can remove all
the
ones
that say more than 1 after. To display all names that haven't been
called
yet
for the specific project.


--
Novice


:

How about you give us a few sample records that accurately describe
what
you
have? Then provide us with how these should display and why.

Are you displaying all of this eventually in a report or form?

--
Duane Hookom
MS Access MVP
--

Duane,
Thanks for your help but I don't understand it...

What I have is Query 'TestList' which shows all records in table
'Doctors'
and all records in table 'Calls' (as calls made to doctors)
This list now shows all doctors once without a call assigned to
it
and
once
with a call assigned to it so some doctorID's appear more than
once.
What I want is to count how many times every doctor ID appears in
the
query.
As I have over 200000 records in this query, I need to filter
this
fast
and
with that little formula that I seek, I would have a fast and
simple
solution
to a long story that frustrates all of my users.
And this formula would then come in a new column in my query.

Sorry if this doesn't make sense.



--
Novice


:

You have to provide some sample records or at least significant
field
and
table names. In order to number your records, you must have a
field
that
identifies which record would be the 1st value and which is the
2nd.

SELECT *, (SELECT Count(*) FROM tblEmployees E WHERE E.Dept =
tblEmployees.Dept And E.HireDate <=tblEmployees.HireDate) as
DeptRank
FROM tblEmployees;

The HireDate is what determines the rank within the department.

--
Duane Hookom
MS Access MVP
--

Okay, might be a ridiculously dumb question but where do I put
the
expression
and how do I fill it out if I am looking to count the
Reoccurring
value
in
field [ID] for Query [Test List]

I tried but get #error


--
Novice


:

Try using the dcount function in your query.

:

Hi all,

I have a query with doubles and I want to know how many
times
the
Record
appears in this query. How do I do that for every row ?

It's a combination of 2 tables that share some common
ground...
so
it
shows
some records several times. How to count them...
I know that in excel it would be
=CountIf(A$2:A$100;A3)
 
D

Duane Hookom

DCount() is horribly slow but you can try the following assuming the ID
field is numeric.

SELECT L.ID, L.[Country ID], L.Region,
L.[Dokter info ID], L.[Name Practice/Hospital],
L.[First name], L.[Last name], L.Title, L.[Male/Female],
L.[Language ID], L.specialisme, L.[Country number],
L.Phonenumber, L.Faxnumber, Called.Practician, Called.[Project ID],
[Practician] & [Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS
Uttryck1,
[ID] & [Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS Uttryck2,
IIf([Praction]=[ID],"Don't","Show") AS Uttryck3,
DCount("*","[Test List]","[ID] = " & L.[ID] ) AS TheCount
FROM [lÄKARE LIST] AS L LEFT JOIN Called
ON L.ID = Called.Practician
WHERE Called.[Project
ID]=[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
Or Called.[Project ID] Is Null;

--
Duane Hookom
MS Access MVP
--

Ben said:
Thanks for being so patient with me.

Well, that doesn't seem to be it... Sorry, I should have written the full
error message. It says " Circular reference caused by 'Test List' "

Isn't there something like dcount that can do like this...
Count(all records in Column [ID], from query [Test List], where the [ID]
from current record is equal)
all in query [test list]




--
Novice


Duane Hookom said:
I think the issue is because you create a column named Uttryck2 and then
use
it in another expression. I avoid this at all cost.

--
Duane Hookom
MS Access MVP
--

Ben said:
I applied it to my existing query sql but I must be doing something
wrong
(circular referens error message shown).
Here is my SQL for Query [Test List]

SELECT L.ID, L.[Country ID], L.Region, L.[Dokter info ID], L.[Name
Practice/Hospital], L.[First name], L.[Last name], L.Title,
L.[Male/Female],
L.[Language ID], L.specialisme, L.[Country number], L.Phonenumber,
L.Faxnumber, Called.Practician, Called.[Project ID], [Practician] &
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS Uttryck1,
[ID]
&
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS Uttryck2,
IIf([Uttryck1]=[Uttryck2],"Don't","Show") AS Uttryck3, (SELECT Count(*)
FROM
[Test List] q WHERE q.[ID] = L.[ID] ) AS TheCount
FROM [lÄKARE LIST] AS L LEFT JOIN Called ON L.ID = Called.Practician
WHERE (((Called.[Project
ID])=[Forms]![SelectProjectforListtocall]![Kombinationsruta0] Or
(Called.[Project ID]) Is Null));


(in case you would wonder:
[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
this is an external factor to eliminate all calls that are not related
to
this project. It will only keep the ID's of doctors that have been
called
for
the chosen project and the complete list of doctors. now I want to
remove
the
doubles in the same query by counting the recurring ID's)



--
Novice


:

You would enter the select statement into the SQL view of a query.
Make
sure
you use your table and field names.

--
Duane Hookom
MS Access MVP
--

And where do I put this ? Sorry for my incompetence


SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];





--
Novice


:

Try
SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];

BTW: I don't care for field/column names that are properties,
functions,
or
sql aggregates (Name, Count)
--
Duane Hookom
MS Access MVP
--

ID Name Project Result COUNT
17 James Test25 Done 2
19 George 2
25 Ben Test25 Cancelled 1
17 James 2
19 George Test25 Done 2
21 Louis 1
07 Ellen 1

ID - Name - Project - Result are taken from tables and exist.
Count
is
what
I look for. It gives a number for the amount of times an ID
(name)
appears
in
the query.

I am going to display them in a continuous form where I will
filter
them
with VBA on click. I just need to get this count so I can remove
all
the
ones
that say more than 1 after. To display all names that haven't
been
called
yet
for the specific project.


--
Novice


:

How about you give us a few sample records that accurately
describe
what
you
have? Then provide us with how these should display and why.

Are you displaying all of this eventually in a report or form?

--
Duane Hookom
MS Access MVP
--

Duane,
Thanks for your help but I don't understand it...

What I have is Query 'TestList' which shows all records in
table
'Doctors'
and all records in table 'Calls' (as calls made to doctors)
This list now shows all doctors once without a call assigned
to
it
and
once
with a call assigned to it so some doctorID's appear more than
once.
What I want is to count how many times every doctor ID appears
in
the
query.
As I have over 200000 records in this query, I need to filter
this
fast
and
with that little formula that I seek, I would have a fast and
simple
solution
to a long story that frustrates all of my users.
And this formula would then come in a new column in my query.

Sorry if this doesn't make sense.



--
Novice


:

You have to provide some sample records or at least
significant
field
and
table names. In order to number your records, you must have a
field
that
identifies which record would be the 1st value and which is
the
2nd.

SELECT *, (SELECT Count(*) FROM tblEmployees E WHERE E.Dept =
tblEmployees.Dept And E.HireDate <=tblEmployees.HireDate) as
DeptRank
FROM tblEmployees;

The HireDate is what determines the rank within the
department.

--
Duane Hookom
MS Access MVP
--

Okay, might be a ridiculously dumb question but where do I
put
the
expression
and how do I fill it out if I am looking to count the
Reoccurring
value
in
field [ID] for Query [Test List]

I tried but get #error


--
Novice


:

Try using the dcount function in your query.

:

Hi all,

I have a query with doubles and I want to know how many
times
the
Record
appears in this query. How do I do that for every row ?

It's a combination of 2 tables that share some common
ground...
so
it
shows
some records several times. How to count them...
I know that in excel it would be
=CountIf(A$2:A$100;A3)
 
G

Guest

I tried... no more circular reference but now just #Error as a result.
I took out all unnecessary stuff now to make it less messy.

SELECT L.ID, Called.Practician, Called.[Project ID], DCount("*","[Test
List]","[ID] = " & L.[ID]) AS TheCount
FROM [Läkare List] AS L LEFT JOIN Called ON L.ID = Called.Practician;

Yes, ID is numeric and is also an autonumber... could that be a reason that
this doesn't work ?
Any other ways to exclude double appearing Records from a query without
creating a new query?

PS, I have something that works but it takes about 8minutes to load because
it loads in 3 different queries towards 1 result...


--
Novice


Duane Hookom said:
DCount() is horribly slow but you can try the following assuming the ID
field is numeric.

SELECT L.ID, L.[Country ID], L.Region,
L.[Dokter info ID], L.[Name Practice/Hospital],
L.[First name], L.[Last name], L.Title, L.[Male/Female],
L.[Language ID], L.specialisme, L.[Country number],
L.Phonenumber, L.Faxnumber, Called.Practician, Called.[Project ID],
[Practician] & [Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS
Uttryck1,
[ID] & [Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS Uttryck2,
IIf([Praction]=[ID],"Don't","Show") AS Uttryck3,
DCount("*","[Test List]","[ID] = " & L.[ID] ) AS TheCount
FROM [lÄKARE LIST] AS L LEFT JOIN Called
ON L.ID = Called.Practician
WHERE Called.[Project
ID]=[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
Or Called.[Project ID] Is Null;

--
Duane Hookom
MS Access MVP
--

Ben said:
Thanks for being so patient with me.

Well, that doesn't seem to be it... Sorry, I should have written the full
error message. It says " Circular reference caused by 'Test List' "

Isn't there something like dcount that can do like this...
Count(all records in Column [ID], from query [Test List], where the [ID]
from current record is equal)
all in query [test list]




--
Novice


Duane Hookom said:
I think the issue is because you create a column named Uttryck2 and then
use
it in another expression. I avoid this at all cost.

--
Duane Hookom
MS Access MVP
--

I applied it to my existing query sql but I must be doing something
wrong
(circular referens error message shown).
Here is my SQL for Query [Test List]

SELECT L.ID, L.[Country ID], L.Region, L.[Dokter info ID], L.[Name
Practice/Hospital], L.[First name], L.[Last name], L.Title,
L.[Male/Female],
L.[Language ID], L.specialisme, L.[Country number], L.Phonenumber,
L.Faxnumber, Called.Practician, Called.[Project ID], [Practician] &
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS Uttryck1,
[ID]
&
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS Uttryck2,
IIf([Uttryck1]=[Uttryck2],"Don't","Show") AS Uttryck3, (SELECT Count(*)
FROM
[Test List] q WHERE q.[ID] = L.[ID] ) AS TheCount
FROM [lÄKARE LIST] AS L LEFT JOIN Called ON L.ID = Called.Practician
WHERE (((Called.[Project
ID])=[Forms]![SelectProjectforListtocall]![Kombinationsruta0] Or
(Called.[Project ID]) Is Null));


(in case you would wonder:
[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
this is an external factor to eliminate all calls that are not related
to
this project. It will only keep the ID's of doctors that have been
called
for
the chosen project and the complete list of doctors. now I want to
remove
the
doubles in the same query by counting the recurring ID's)



--
Novice


:

You would enter the select statement into the SQL view of a query.
Make
sure
you use your table and field names.

--
Duane Hookom
MS Access MVP
--

And where do I put this ? Sorry for my incompetence


SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];





--
Novice


:

Try
SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];

BTW: I don't care for field/column names that are properties,
functions,
or
sql aggregates (Name, Count)
--
Duane Hookom
MS Access MVP
--

ID Name Project Result COUNT
17 James Test25 Done 2
19 George 2
25 Ben Test25 Cancelled 1
17 James 2
19 George Test25 Done 2
21 Louis 1
07 Ellen 1

ID - Name - Project - Result are taken from tables and exist.
Count
is
what
I look for. It gives a number for the amount of times an ID
(name)
appears
in
the query.

I am going to display them in a continuous form where I will
filter
them
with VBA on click. I just need to get this count so I can remove
all
the
ones
that say more than 1 after. To display all names that haven't
been
called
yet
for the specific project.


--
Novice


:

How about you give us a few sample records that accurately
describe
what
you
have? Then provide us with how these should display and why.

Are you displaying all of this eventually in a report or form?

--
Duane Hookom
MS Access MVP
--

Duane,
Thanks for your help but I don't understand it...

What I have is Query 'TestList' which shows all records in
table
'Doctors'
and all records in table 'Calls' (as calls made to doctors)
This list now shows all doctors once without a call assigned
to
it
and
once
with a call assigned to it so some doctorID's appear more than
once.
What I want is to count how many times every doctor ID appears
in
the
query.
As I have over 200000 records in this query, I need to filter
this
fast
and
with that little formula that I seek, I would have a fast and
simple
solution
to a long story that frustrates all of my users.
And this formula would then come in a new column in my query.

Sorry if this doesn't make sense.



--
Novice


:

You have to provide some sample records or at least
significant
field
and
table names. In order to number your records, you must have a
field
that
identifies which record would be the 1st value and which is
the
2nd.

SELECT *, (SELECT Count(*) FROM tblEmployees E WHERE E.Dept =
tblEmployees.Dept And E.HireDate <=tblEmployees.HireDate) as
DeptRank
FROM tblEmployees;

The HireDate is what determines the rank within the
department.

--
Duane Hookom
MS Access MVP
--

Okay, might be a ridiculously dumb question but where do I
put
the
expression
and how do I fill it out if I am looking to count the
Reoccurring
value
in
field [ID] for Query [Test List]

I tried but get #error


--
Novice


:

Try using the dcount function in your query.

:

Hi all,

I have a query with doubles and I want to know how many
times
the
Record
appears in this query. How do I do that for every row ?

It's a combination of 2 tables that share some common
ground...
so
 
D

Duane Hookom

Open the debug/immediate window (press Ctrl+G) and enter:
? DCount("*","[Test List]")

Replace the 99 with a legitimate ID value in the following:
? DCount("*","[Test List]","[ID] = 99")

--
Duane Hookom
MS Access MVP
--

Ben said:
I tried... no more circular reference but now just #Error as a result.
I took out all unnecessary stuff now to make it less messy.

SELECT L.ID, Called.Practician, Called.[Project ID], DCount("*","[Test
List]","[ID] = " & L.[ID]) AS TheCount
FROM [Läkare List] AS L LEFT JOIN Called ON L.ID = Called.Practician;

Yes, ID is numeric and is also an autonumber... could that be a reason
that
this doesn't work ?
Any other ways to exclude double appearing Records from a query without
creating a new query?

PS, I have something that works but it takes about 8minutes to load
because
it loads in 3 different queries towards 1 result...


--
Novice


Duane Hookom said:
DCount() is horribly slow but you can try the following assuming the ID
field is numeric.

SELECT L.ID, L.[Country ID], L.Region,
L.[Dokter info ID], L.[Name Practice/Hospital],
L.[First name], L.[Last name], L.Title, L.[Male/Female],
L.[Language ID], L.specialisme, L.[Country number],
L.Phonenumber, L.Faxnumber, Called.Practician, Called.[Project ID],
[Practician] & [Forms]![SelectProjectforListtocall]![Kombinationsruta0]
AS
Uttryck1,
[ID] & [Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS
Uttryck2,
IIf([Praction]=[ID],"Don't","Show") AS Uttryck3,
DCount("*","[Test List]","[ID] = " & L.[ID] ) AS TheCount
FROM [lÄKARE LIST] AS L LEFT JOIN Called
ON L.ID = Called.Practician
WHERE Called.[Project
ID]=[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
Or Called.[Project ID] Is Null;

--
Duane Hookom
MS Access MVP
--

Ben said:
Thanks for being so patient with me.

Well, that doesn't seem to be it... Sorry, I should have written the
full
error message. It says " Circular reference caused by 'Test List' "

Isn't there something like dcount that can do like this...
Count(all records in Column [ID], from query [Test List], where the
[ID]
from current record is equal)
all in query [test list]




--
Novice


:

I think the issue is because you create a column named Uttryck2 and
then
use
it in another expression. I avoid this at all cost.

--
Duane Hookom
MS Access MVP
--

I applied it to my existing query sql but I must be doing something
wrong
(circular referens error message shown).
Here is my SQL for Query [Test List]

SELECT L.ID, L.[Country ID], L.Region, L.[Dokter info ID], L.[Name
Practice/Hospital], L.[First name], L.[Last name], L.Title,
L.[Male/Female],
L.[Language ID], L.specialisme, L.[Country number], L.Phonenumber,
L.Faxnumber, Called.Practician, Called.[Project ID], [Practician] &
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS
Uttryck1,
[ID]
&
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS
Uttryck2,
IIf([Uttryck1]=[Uttryck2],"Don't","Show") AS Uttryck3, (SELECT
Count(*)
FROM
[Test List] q WHERE q.[ID] = L.[ID] ) AS TheCount
FROM [lÄKARE LIST] AS L LEFT JOIN Called ON L.ID = Called.Practician
WHERE (((Called.[Project
ID])=[Forms]![SelectProjectforListtocall]![Kombinationsruta0] Or
(Called.[Project ID]) Is Null));


(in case you would wonder:
[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
this is an external factor to eliminate all calls that are not
related
to
this project. It will only keep the ID's of doctors that have been
called
for
the chosen project and the complete list of doctors. now I want to
remove
the
doubles in the same query by counting the recurring ID's)



--
Novice


:

You would enter the select statement into the SQL view of a query.
Make
sure
you use your table and field names.

--
Duane Hookom
MS Access MVP
--

And where do I put this ? Sorry for my incompetence


SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];





--
Novice


:

Try
SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];

BTW: I don't care for field/column names that are properties,
functions,
or
sql aggregates (Name, Count)
--
Duane Hookom
MS Access MVP
--

ID Name Project Result COUNT
17 James Test25 Done 2
19 George 2
25 Ben Test25 Cancelled 1
17 James 2
19 George Test25 Done 2
21 Louis 1
07 Ellen 1

ID - Name - Project - Result are taken from tables and exist.
Count
is
what
I look for. It gives a number for the amount of times an ID
(name)
appears
in
the query.

I am going to display them in a continuous form where I will
filter
them
with VBA on click. I just need to get this count so I can
remove
all
the
ones
that say more than 1 after. To display all names that haven't
been
called
yet
for the specific project.


--
Novice


:

How about you give us a few sample records that accurately
describe
what
you
have? Then provide us with how these should display and why.

Are you displaying all of this eventually in a report or
form?

--
Duane Hookom
MS Access MVP
--

Duane,
Thanks for your help but I don't understand it...

What I have is Query 'TestList' which shows all records in
table
'Doctors'
and all records in table 'Calls' (as calls made to doctors)
This list now shows all doctors once without a call
assigned
to
it
and
once
with a call assigned to it so some doctorID's appear more
than
once.
What I want is to count how many times every doctor ID
appears
in
the
query.
As I have over 200000 records in this query, I need to
filter
this
fast
and
with that little formula that I seek, I would have a fast
and
simple
solution
to a long story that frustrates all of my users.
And this formula would then come in a new column in my
query.

Sorry if this doesn't make sense.



--
Novice


:

You have to provide some sample records or at least
significant
field
and
table names. In order to number your records, you must
have a
field
that
identifies which record would be the 1st value and which
is
the
2nd.

SELECT *, (SELECT Count(*) FROM tblEmployees E WHERE
E.Dept =
tblEmployees.Dept And E.HireDate <=tblEmployees.HireDate)
as
DeptRank
FROM tblEmployees;

The HireDate is what determines the rank within the
department.

--
Duane Hookom
MS Access MVP
--

Okay, might be a ridiculously dumb question but where do
I
put
the
expression
and how do I fill it out if I am looking to count the
Reoccurring
value
in
field [ID] for Query [Test List]

I tried but get #error


--
Novice


:

Try using the dcount function in your query.

:

Hi all,

I have a query with doubles and I want to know how
many
times
the
Record
appears in this query. How do I do that for every row
?

It's a combination of 2 tables that share some common
ground...
so
 
G

Guest

Thanks a million!
Well, For some unexplained reason the result appeared... without new changes.

But unfortunately, after testing it on my test data... it is not giving the
expected result nor speed increase...

Any other suggestions to achieve my goals.
Table Doctors (Läkare List)
ID
First Name
Last Name

Table Project
Project ID
Project Name

Table Called
Call ID
ID (Relation to Table Läkare List)
Project ID (Relation to Table Project)

Goal: Create a list of doctors that haven't been called yet and this For
each Project




--
Novice


Duane Hookom said:
Open the debug/immediate window (press Ctrl+G) and enter:
? DCount("*","[Test List]")

Replace the 99 with a legitimate ID value in the following:
? DCount("*","[Test List]","[ID] = 99")

--
Duane Hookom
MS Access MVP
--

Ben said:
I tried... no more circular reference but now just #Error as a result.
I took out all unnecessary stuff now to make it less messy.

SELECT L.ID, Called.Practician, Called.[Project ID], DCount("*","[Test
List]","[ID] = " & L.[ID]) AS TheCount
FROM [Läkare List] AS L LEFT JOIN Called ON L.ID = Called.Practician;

Yes, ID is numeric and is also an autonumber... could that be a reason
that
this doesn't work ?
Any other ways to exclude double appearing Records from a query without
creating a new query?

PS, I have something that works but it takes about 8minutes to load
because
it loads in 3 different queries towards 1 result...


--
Novice


Duane Hookom said:
DCount() is horribly slow but you can try the following assuming the ID
field is numeric.

SELECT L.ID, L.[Country ID], L.Region,
L.[Dokter info ID], L.[Name Practice/Hospital],
L.[First name], L.[Last name], L.Title, L.[Male/Female],
L.[Language ID], L.specialisme, L.[Country number],
L.Phonenumber, L.Faxnumber, Called.Practician, Called.[Project ID],
[Practician] & [Forms]![SelectProjectforListtocall]![Kombinationsruta0]
AS
Uttryck1,
[ID] & [Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS
Uttryck2,
IIf([Praction]=[ID],"Don't","Show") AS Uttryck3,
DCount("*","[Test List]","[ID] = " & L.[ID] ) AS TheCount
FROM [lÄKARE LIST] AS L LEFT JOIN Called
ON L.ID = Called.Practician
WHERE Called.[Project
ID]=[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
Or Called.[Project ID] Is Null;

--
Duane Hookom
MS Access MVP
--

Thanks for being so patient with me.

Well, that doesn't seem to be it... Sorry, I should have written the
full
error message. It says " Circular reference caused by 'Test List' "

Isn't there something like dcount that can do like this...
Count(all records in Column [ID], from query [Test List], where the
[ID]
from current record is equal)
all in query [test list]




--
Novice


:

I think the issue is because you create a column named Uttryck2 and
then
use
it in another expression. I avoid this at all cost.

--
Duane Hookom
MS Access MVP
--

I applied it to my existing query sql but I must be doing something
wrong
(circular referens error message shown).
Here is my SQL for Query [Test List]

SELECT L.ID, L.[Country ID], L.Region, L.[Dokter info ID], L.[Name
Practice/Hospital], L.[First name], L.[Last name], L.Title,
L.[Male/Female],
L.[Language ID], L.specialisme, L.[Country number], L.Phonenumber,
L.Faxnumber, Called.Practician, Called.[Project ID], [Practician] &
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS
Uttryck1,
[ID]
&
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS
Uttryck2,
IIf([Uttryck1]=[Uttryck2],"Don't","Show") AS Uttryck3, (SELECT
Count(*)
FROM
[Test List] q WHERE q.[ID] = L.[ID] ) AS TheCount
FROM [lÄKARE LIST] AS L LEFT JOIN Called ON L.ID = Called.Practician
WHERE (((Called.[Project
ID])=[Forms]![SelectProjectforListtocall]![Kombinationsruta0] Or
(Called.[Project ID]) Is Null));


(in case you would wonder:
[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
this is an external factor to eliminate all calls that are not
related
to
this project. It will only keep the ID's of doctors that have been
called
for
the chosen project and the complete list of doctors. now I want to
remove
the
doubles in the same query by counting the recurring ID's)



--
Novice


:

You would enter the select statement into the SQL view of a query.
Make
sure
you use your table and field names.

--
Duane Hookom
MS Access MVP
--

And where do I put this ? Sorry for my incompetence


SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];





--
Novice


:

Try
SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];

BTW: I don't care for field/column names that are properties,
functions,
or
sql aggregates (Name, Count)
--
Duane Hookom
MS Access MVP
--

ID Name Project Result COUNT
17 James Test25 Done 2
19 George 2
25 Ben Test25 Cancelled 1
17 James 2
19 George Test25 Done 2
21 Louis 1
07 Ellen 1

ID - Name - Project - Result are taken from tables and exist.
Count
is
what
I look for. It gives a number for the amount of times an ID
(name)
appears
in
the query.

I am going to display them in a continuous form where I will
filter
them
with VBA on click. I just need to get this count so I can
remove
all
the
ones
that say more than 1 after. To display all names that haven't
been
called
yet
for the specific project.


--
Novice


:

How about you give us a few sample records that accurately
describe
what
you
have? Then provide us with how these should display and why.

Are you displaying all of this eventually in a report or
form?

--
Duane Hookom
MS Access MVP
--

Duane,
Thanks for your help but I don't understand it...

What I have is Query 'TestList' which shows all records in
table
'Doctors'
and all records in table 'Calls' (as calls made to doctors)
This list now shows all doctors once without a call
assigned
to
it
and
once
with a call assigned to it so some doctorID's appear more
than
once.
What I want is to count how many times every doctor ID
appears
in
the
query.
As I have over 200000 records in this query, I need to
filter
this
fast
and
with that little formula that I seek, I would have a fast
and
simple
solution
to a long story that frustrates all of my users.
And this formula would then come in a new column in my
query.

Sorry if this doesn't make sense.



--
Novice


:

You have to provide some sample records or at least
significant
field
and
table names. In order to number your records, you must
have a
 
D

Duane Hookom

If you want a list of Doctors not associated with each project,
-create a cartesian query of all doctors and projects (qcarDoctorProjects):
SELECT Project.[Project ID], Project.[Project Name],
Doctors.ID, Doctors.[First Name], Doctors.[Last Name]
FROM Project, Doctors;
-create a LEFT JOIN query based on qcarDoctorProjects and the Called table:
SELECT qcarDoctorProjects.[Project ID], qcarDoctorProjects.[Project Name],
qcarDoctorProjects.ID, qcarDoctorProjects.[First Name],
qcarDoctorProjects.[Last Name]
FROM qcarDoctorProjects LEFT JOIN
Called ON (qcarDoctorProjects.ID = Called.ID) AND
(qcarDoctorProjects.[Project ID] = Called.[Project ID])
WHERE (((Called.[Call ID]) Is Null));

--
Duane Hookom
MS Access MVP
--

Ben said:
Thanks a million!
Well, For some unexplained reason the result appeared... without new
changes.

But unfortunately, after testing it on my test data... it is not giving
the
expected result nor speed increase...

Any other suggestions to achieve my goals.
Table Doctors (Läkare List)
ID
First Name
Last Name

Table Project
Project ID
Project Name

Table Called
Call ID
ID (Relation to Table Läkare List)
Project ID (Relation to Table Project)

Goal: Create a list of doctors that haven't been called yet and this For
each Project




--
Novice


Duane Hookom said:
Open the debug/immediate window (press Ctrl+G) and enter:
? DCount("*","[Test List]")

Replace the 99 with a legitimate ID value in the following:
? DCount("*","[Test List]","[ID] = 99")

--
Duane Hookom
MS Access MVP
--

Ben said:
I tried... no more circular reference but now just #Error as a result.
I took out all unnecessary stuff now to make it less messy.

SELECT L.ID, Called.Practician, Called.[Project ID], DCount("*","[Test
List]","[ID] = " & L.[ID]) AS TheCount
FROM [Läkare List] AS L LEFT JOIN Called ON L.ID = Called.Practician;

Yes, ID is numeric and is also an autonumber... could that be a reason
that
this doesn't work ?
Any other ways to exclude double appearing Records from a query without
creating a new query?

PS, I have something that works but it takes about 8minutes to load
because
it loads in 3 different queries towards 1 result...


--
Novice


:

DCount() is horribly slow but you can try the following assuming the
ID
field is numeric.

SELECT L.ID, L.[Country ID], L.Region,
L.[Dokter info ID], L.[Name Practice/Hospital],
L.[First name], L.[Last name], L.Title, L.[Male/Female],
L.[Language ID], L.specialisme, L.[Country number],
L.Phonenumber, L.Faxnumber, Called.Practician, Called.[Project ID],
[Practician] &
[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
AS
Uttryck1,
[ID] & [Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS
Uttryck2,
IIf([Praction]=[ID],"Don't","Show") AS Uttryck3,
DCount("*","[Test List]","[ID] = " & L.[ID] ) AS TheCount
FROM [lÄKARE LIST] AS L LEFT JOIN Called
ON L.ID = Called.Practician
WHERE Called.[Project
ID]=[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
Or Called.[Project ID] Is Null;

--
Duane Hookom
MS Access MVP
--

Thanks for being so patient with me.

Well, that doesn't seem to be it... Sorry, I should have written the
full
error message. It says " Circular reference caused by 'Test List' "

Isn't there something like dcount that can do like this...
Count(all records in Column [ID], from query [Test List], where the
[ID]
from current record is equal)
all in query [test list]




--
Novice


:

I think the issue is because you create a column named Uttryck2 and
then
use
it in another expression. I avoid this at all cost.

--
Duane Hookom
MS Access MVP
--

I applied it to my existing query sql but I must be doing
something
wrong
(circular referens error message shown).
Here is my SQL for Query [Test List]

SELECT L.ID, L.[Country ID], L.Region, L.[Dokter info ID],
L.[Name
Practice/Hospital], L.[First name], L.[Last name], L.Title,
L.[Male/Female],
L.[Language ID], L.specialisme, L.[Country number],
L.Phonenumber,
L.Faxnumber, Called.Practician, Called.[Project ID], [Practician]
&
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS
Uttryck1,
[ID]
&
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS
Uttryck2,
IIf([Uttryck1]=[Uttryck2],"Don't","Show") AS Uttryck3, (SELECT
Count(*)
FROM
[Test List] q WHERE q.[ID] = L.[ID] ) AS TheCount
FROM [lÄKARE LIST] AS L LEFT JOIN Called ON L.ID =
Called.Practician
WHERE (((Called.[Project
ID])=[Forms]![SelectProjectforListtocall]![Kombinationsruta0] Or
(Called.[Project ID]) Is Null));


(in case you would wonder:
[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
this is an external factor to eliminate all calls that are not
related
to
this project. It will only keep the ID's of doctors that have
been
called
for
the chosen project and the complete list of doctors. now I want
to
remove
the
doubles in the same query by counting the recurring ID's)



--
Novice


:

You would enter the select statement into the SQL view of a
query.
Make
sure
you use your table and field names.

--
Duane Hookom
MS Access MVP
--

And where do I put this ? Sorry for my incompetence


SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];





--
Novice


:

Try
SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];

BTW: I don't care for field/column names that are properties,
functions,
or
sql aggregates (Name, Count)
--
Duane Hookom
MS Access MVP
--

ID Name Project Result COUNT
17 James Test25 Done 2
19 George 2
25 Ben Test25 Cancelled 1
17 James 2
19 George Test25 Done 2
21 Louis
1
07 Ellen
1

ID - Name - Project - Result are taken from tables and
exist.
Count
is
what
I look for. It gives a number for the amount of times an ID
(name)
appears
in
the query.

I am going to display them in a continuous form where I
will
filter
them
with VBA on click. I just need to get this count so I can
remove
all
the
ones
that say more than 1 after. To display all names that
haven't
been
called
yet
for the specific project.


--
Novice


:

How about you give us a few sample records that accurately
describe
what
you
have? Then provide us with how these should display and
why.

Are you displaying all of this eventually in a report or
form?

--
Duane Hookom
MS Access MVP
--

Duane,
Thanks for your help but I don't understand it...

What I have is Query 'TestList' which shows all records
in
table
'Doctors'
and all records in table 'Calls' (as calls made to
doctors)
This list now shows all doctors once without a call
assigned
to
it
and
once
with a call assigned to it so some doctorID's appear
more
than
once.
What I want is to count how many times every doctor ID
appears
in
the
query.
As I have over 200000 records in this query, I need to
filter
this
fast
and
with that little formula that I seek, I would have a
fast
and
simple
solution
to a long story that frustrates all of my users.
And this formula would then come in a new column in my
query.

Sorry if this doesn't make sense.



--
Novice


:

You have to provide some sample records or at least
significant
field
and
table names. In order to number your records, you must
have a
 
G

Guest

First of all... if you are fed up with me/it, let me know and I will find
other solutions to solve this problem.

I tried it and it gave me a list of enormously many rows. And it seems to
take away exactly those that i need. As I said before, I succeeded in
creating something like I need but it is just too slow and my goal is to
speed it up. Here's what I had.
3queries.


Number1

SELECT [First name], [Last name], [Male/Female],
[Language ID], specialisme, Phonenumber,
[First name] & " " & [Last name] & " " &
Forms!SelectProjectforListtocall!Kombinationsruta0 AS Uttryck1,
ID, [Country ID], Action, Actionby, Actionforproject
FROM [Läkare List]


Number2
SELECT C.Practician AS Uttryck2, C.[Project ID], L.[First name], L.[Last
name], [L].[First name] & " " & [L].[Last name] & " " & [c].[Project ID] AS
Uttryck1, C.Called
FROM Called AS C INNER JOIN [Läkare List] AS L ON C.Practician = L.ID
WHERE (((C.Called)=True));


Number 3

SELECT [For list to call1].[First name], [For list to call1].[Last name],
[For list to
call1].[Male/Female], [For list to call1].[Language ID], [For list to
call1].specialisme, [For list to
call1].Phonenumber, [For list to call1].Uttryck1, [For list to
call2].Uttryck1, IIf([For list to
call1.Uttryck1]=[For list to call2].[Uttryck1],"No","Yes")
AS Uttryck2,
[For list to call1].ID, Language.Language, Speciality.Speciality, [For list
to call1].[Country ID],
[For list to call1].Action, [For list to call1].Actionby, [For list to
call1].Actionforproject
FROM
(([For list to call1]
LEFT JOIN [For list to call2]
ON [For list to call1].Uttryck1 = [For list to call2].Uttryck1)
LEFT JOIN [Language]
ON [For list to call1].[Language ID] = Language.[Language ID])
LEFT JOIN Speciality
ON [For list to call1].specialisme = Speciality.SpecialityID
WHERE ((([For list to call1].specialisme)=
[Forms]![SelectProjectforListtocall]![Kombinationsruta13])
AND (([For list to call1].[Country
ID])=[Forms]![SelectProjectforListtocall]![Kombinationsruta28])
AND ((IIf([For list to call1].[Uttryck1]=[For list to
call2].[Uttryck1],"No","Yes"))="Yes"))

OR ((([For list to call1].specialisme)=
[Forms]![SelectProjectforListtocall]![Kombinationsruta13])
AND ((IIf([For list to call1].[Uttryck1]=[For list to
call2].[Uttryck1],"No","Yes"))="Yes")
AND (([Forms]![SelectProjectforListtocall]![Kombinationsruta28]) Is Null))

OR ((([For list to
call1].specialisme)=[Forms]![SelectProjectforListtocall]![Kombinationsruta13])
AND (([For list to call1].[Country
ID])=[Forms]![SelectProjectforListtocall]![Kombinationsruta28])
AND ((IIf([For list to call1].[Uttryck1]=[For list to
call2].[Uttryck1],"No","Yes"))="Yes"))

OR ((([For list to
call1].specialisme)=[Forms]![SelectProjectforListtocall]![Kombinationsruta13])
AND ((IIf([For list to call1].[Uttryck1]=[For list to
call2].[Uttryck1],"No","Yes"))="Yes")
AND (([Forms]![SelectProjectforListtocall]![Kombinationsruta28]) Is Null))

OR ((([For list to call1].[Country
ID])=[Forms]![SelectProjectforListtocall]![Kombinationsruta28])
AND ((IIf([For list to call1.Uttryck1]=[For list to call2.Uttryck1],
"No","Yes"))="Yes")
AND (([Forms]![SelectProjectforListtocall]![Kombinationsruta13]) Is Null))

OR (((IIf([For list to call1].[Uttryck1]=[For list to
call2].[Uttryck1],"No","Yes"))="Yes")
AND (([Forms]![SelectProjectforListtocall]![Kombinationsruta28]) Is Null)
AND (([Forms]![SelectProjectforListtocall]![Kombinationsruta13]) Is Null));

Still based on doctors (läkare list or L), Project and Called

--
Novice


Duane Hookom said:
If you want a list of Doctors not associated with each project,
-create a cartesian query of all doctors and projects (qcarDoctorProjects):
SELECT Project.[Project ID], Project.[Project Name],
Doctors.ID, Doctors.[First Name], Doctors.[Last Name]
FROM Project, Doctors;
-create a LEFT JOIN query based on qcarDoctorProjects and the Called table:
SELECT qcarDoctorProjects.[Project ID], qcarDoctorProjects.[Project Name],
qcarDoctorProjects.ID, qcarDoctorProjects.[First Name],
qcarDoctorProjects.[Last Name]
FROM qcarDoctorProjects LEFT JOIN
Called ON (qcarDoctorProjects.ID = Called.ID) AND
(qcarDoctorProjects.[Project ID] = Called.[Project ID])
WHERE (((Called.[Call ID]) Is Null));

--
Duane Hookom
MS Access MVP
--

Ben said:
Thanks a million!
Well, For some unexplained reason the result appeared... without new
changes.

But unfortunately, after testing it on my test data... it is not giving
the
expected result nor speed increase...

Any other suggestions to achieve my goals.
Table Doctors (Läkare List)
ID
First Name
Last Name

Table Project
Project ID
Project Name

Table Called
Call ID
ID (Relation to Table Läkare List)
Project ID (Relation to Table Project)

Goal: Create a list of doctors that haven't been called yet and this For
each Project




--
Novice


Duane Hookom said:
Open the debug/immediate window (press Ctrl+G) and enter:
? DCount("*","[Test List]")

Replace the 99 with a legitimate ID value in the following:
? DCount("*","[Test List]","[ID] = 99")

--
Duane Hookom
MS Access MVP
--

I tried... no more circular reference but now just #Error as a result.
I took out all unnecessary stuff now to make it less messy.

SELECT L.ID, Called.Practician, Called.[Project ID], DCount("*","[Test
List]","[ID] = " & L.[ID]) AS TheCount
FROM [Läkare List] AS L LEFT JOIN Called ON L.ID = Called.Practician;

Yes, ID is numeric and is also an autonumber... could that be a reason
that
this doesn't work ?
Any other ways to exclude double appearing Records from a query without
creating a new query?

PS, I have something that works but it takes about 8minutes to load
because
it loads in 3 different queries towards 1 result...


--
Novice


:

DCount() is horribly slow but you can try the following assuming the
ID
field is numeric.

SELECT L.ID, L.[Country ID], L.Region,
L.[Dokter info ID], L.[Name Practice/Hospital],
L.[First name], L.[Last name], L.Title, L.[Male/Female],
L.[Language ID], L.specialisme, L.[Country number],
L.Phonenumber, L.Faxnumber, Called.Practician, Called.[Project ID],
[Practician] &
[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
AS
Uttryck1,
[ID] & [Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS
Uttryck2,
IIf([Praction]=[ID],"Don't","Show") AS Uttryck3,
DCount("*","[Test List]","[ID] = " & L.[ID] ) AS TheCount
FROM [lÄKARE LIST] AS L LEFT JOIN Called
ON L.ID = Called.Practician
WHERE Called.[Project
ID]=[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
Or Called.[Project ID] Is Null;

--
Duane Hookom
MS Access MVP
--

Thanks for being so patient with me.

Well, that doesn't seem to be it... Sorry, I should have written the
full
error message. It says " Circular reference caused by 'Test List' "

Isn't there something like dcount that can do like this...
Count(all records in Column [ID], from query [Test List], where the
[ID]
from current record is equal)
all in query [test list]




--
Novice


:

I think the issue is because you create a column named Uttryck2 and
then
use
it in another expression. I avoid this at all cost.

--
Duane Hookom
MS Access MVP
--

I applied it to my existing query sql but I must be doing
something
wrong
(circular referens error message shown).
Here is my SQL for Query [Test List]

SELECT L.ID, L.[Country ID], L.Region, L.[Dokter info ID],
L.[Name
Practice/Hospital], L.[First name], L.[Last name], L.Title,
L.[Male/Female],
L.[Language ID], L.specialisme, L.[Country number],
L.Phonenumber,
L.Faxnumber, Called.Practician, Called.[Project ID], [Practician]
&
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS
Uttryck1,
[ID]
&
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS
Uttryck2,
IIf([Uttryck1]=[Uttryck2],"Don't","Show") AS Uttryck3, (SELECT
Count(*)
FROM
[Test List] q WHERE q.[ID] = L.[ID] ) AS TheCount
FROM [lÄKARE LIST] AS L LEFT JOIN Called ON L.ID =
Called.Practician
WHERE (((Called.[Project
ID])=[Forms]![SelectProjectforListtocall]![Kombinationsruta0] Or
(Called.[Project ID]) Is Null));


(in case you would wonder:
[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
this is an external factor to eliminate all calls that are not
related
to
this project. It will only keep the ID's of doctors that have
been
called
for
the chosen project and the complete list of doctors. now I want
to
remove
the
doubles in the same query by counting the recurring ID's)



--
Novice


:

You would enter the select statement into the SQL view of a
query.
Make
sure
you use your table and field names.

--
Duane Hookom
MS Access MVP
--

And where do I put this ? Sorry for my incompetence


SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];





--
Novice


:

Try
SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];

BTW: I don't care for field/column names that are properties,
functions,
or
sql aggregates (Name, Count)
--
Duane Hookom
MS Access MVP
--

ID Name Project Result COUNT
17 James Test25 Done 2
19 George 2
25 Ben Test25 Cancelled 1
17 James 2
19 George Test25 Done 2
21 Louis
1
07 Ellen
1

ID - Name - Project - Result are taken from tables and
exist.
Count
is
what
I look for. It gives a number for the amount of times an ID
(name)
appears
in
the query.

I am going to display them in a continuous form where I
will
filter
them
with VBA on click. I just need to get this count so I can
remove
all
the
ones
that say more than 1 after. To display all names that
haven't
been
called
yet
for the specific project.


--
 
D

Duane Hookom

I understood your goal :"Create a list of doctors that haven't been called
yet and this For each Project" to mean that you wanted a list of all
project/doctor combinations that were not in the Called table.

--
Duane Hookom
MS Access MVP
--

Ben said:
First of all... if you are fed up with me/it, let me know and I will find
other solutions to solve this problem.

I tried it and it gave me a list of enormously many rows. And it seems to
take away exactly those that i need. As I said before, I succeeded in
creating something like I need but it is just too slow and my goal is to
speed it up. Here's what I had.
3queries.


Number1

SELECT [First name], [Last name], [Male/Female],
[Language ID], specialisme, Phonenumber,
[First name] & " " & [Last name] & " " &
Forms!SelectProjectforListtocall!Kombinationsruta0 AS Uttryck1,
ID, [Country ID], Action, Actionby, Actionforproject
FROM [Läkare List]


Number2
SELECT C.Practician AS Uttryck2, C.[Project ID], L.[First name], L.[Last
name], [L].[First name] & " " & [L].[Last name] & " " & [c].[Project ID]
AS
Uttryck1, C.Called
FROM Called AS C INNER JOIN [Läkare List] AS L ON C.Practician = L.ID
WHERE (((C.Called)=True));


Number 3

SELECT [For list to call1].[First name], [For list to call1].[Last name],
[For list to
call1].[Male/Female], [For list to call1].[Language ID], [For list to
call1].specialisme, [For list to
call1].Phonenumber, [For list to call1].Uttryck1, [For list to
call2].Uttryck1, IIf([For list to
call1.Uttryck1]=[For list to call2].[Uttryck1],"No","Yes")
AS Uttryck2,
[For list to call1].ID, Language.Language, Speciality.Speciality, [For
list
to call1].[Country ID],
[For list to call1].Action, [For list to call1].Actionby, [For list to
call1].Actionforproject
FROM
(([For list to call1]
LEFT JOIN [For list to call2]
ON [For list to call1].Uttryck1 = [For list to call2].Uttryck1)
LEFT JOIN [Language]
ON [For list to call1].[Language ID] = Language.[Language ID])
LEFT JOIN Speciality
ON [For list to call1].specialisme = Speciality.SpecialityID
WHERE ((([For list to call1].specialisme)=
[Forms]![SelectProjectforListtocall]![Kombinationsruta13])
AND (([For list to call1].[Country
ID])=[Forms]![SelectProjectforListtocall]![Kombinationsruta28])
AND ((IIf([For list to call1].[Uttryck1]=[For list to
call2].[Uttryck1],"No","Yes"))="Yes"))

OR ((([For list to call1].specialisme)=
[Forms]![SelectProjectforListtocall]![Kombinationsruta13])
AND ((IIf([For list to call1].[Uttryck1]=[For list to
call2].[Uttryck1],"No","Yes"))="Yes")
AND (([Forms]![SelectProjectforListtocall]![Kombinationsruta28]) Is Null))

OR ((([For list to
call1].specialisme)=[Forms]![SelectProjectforListtocall]![Kombinationsruta13])
AND (([For list to call1].[Country
ID])=[Forms]![SelectProjectforListtocall]![Kombinationsruta28])
AND ((IIf([For list to call1].[Uttryck1]=[For list to
call2].[Uttryck1],"No","Yes"))="Yes"))

OR ((([For list to
call1].specialisme)=[Forms]![SelectProjectforListtocall]![Kombinationsruta13])
AND ((IIf([For list to call1].[Uttryck1]=[For list to
call2].[Uttryck1],"No","Yes"))="Yes")
AND (([Forms]![SelectProjectforListtocall]![Kombinationsruta28]) Is Null))

OR ((([For list to call1].[Country
ID])=[Forms]![SelectProjectforListtocall]![Kombinationsruta28])
AND ((IIf([For list to call1.Uttryck1]=[For list to call2.Uttryck1],
"No","Yes"))="Yes")
AND (([Forms]![SelectProjectforListtocall]![Kombinationsruta13]) Is Null))

OR (((IIf([For list to call1].[Uttryck1]=[For list to
call2].[Uttryck1],"No","Yes"))="Yes")
AND (([Forms]![SelectProjectforListtocall]![Kombinationsruta28]) Is Null)
AND (([Forms]![SelectProjectforListtocall]![Kombinationsruta13]) Is
Null));

Still based on doctors (läkare list or L), Project and Called

--
Novice


Duane Hookom said:
If you want a list of Doctors not associated with each project,
-create a cartesian query of all doctors and projects
(qcarDoctorProjects):
SELECT Project.[Project ID], Project.[Project Name],
Doctors.ID, Doctors.[First Name], Doctors.[Last Name]
FROM Project, Doctors;
-create a LEFT JOIN query based on qcarDoctorProjects and the Called
table:
SELECT qcarDoctorProjects.[Project ID], qcarDoctorProjects.[Project
Name],
qcarDoctorProjects.ID, qcarDoctorProjects.[First Name],
qcarDoctorProjects.[Last Name]
FROM qcarDoctorProjects LEFT JOIN
Called ON (qcarDoctorProjects.ID = Called.ID) AND
(qcarDoctorProjects.[Project ID] = Called.[Project ID])
WHERE (((Called.[Call ID]) Is Null));

--
Duane Hookom
MS Access MVP
--

Ben said:
Thanks a million!
Well, For some unexplained reason the result appeared... without new
changes.

But unfortunately, after testing it on my test data... it is not giving
the
expected result nor speed increase...

Any other suggestions to achieve my goals.
Table Doctors (Läkare List)
ID
First Name
Last Name

Table Project
Project ID
Project Name

Table Called
Call ID
ID (Relation to Table Läkare List)
Project ID (Relation to Table Project)

Goal: Create a list of doctors that haven't been called yet and this
For
each Project




--
Novice


:

Open the debug/immediate window (press Ctrl+G) and enter:
? DCount("*","[Test List]")

Replace the 99 with a legitimate ID value in the following:
? DCount("*","[Test List]","[ID] = 99")

--
Duane Hookom
MS Access MVP
--

I tried... no more circular reference but now just #Error as a
result.
I took out all unnecessary stuff now to make it less messy.

SELECT L.ID, Called.Practician, Called.[Project ID],
DCount("*","[Test
List]","[ID] = " & L.[ID]) AS TheCount
FROM [Läkare List] AS L LEFT JOIN Called ON L.ID =
Called.Practician;

Yes, ID is numeric and is also an autonumber... could that be a
reason
that
this doesn't work ?
Any other ways to exclude double appearing Records from a query
without
creating a new query?

PS, I have something that works but it takes about 8minutes to load
because
it loads in 3 different queries towards 1 result...


--
Novice


:

DCount() is horribly slow but you can try the following assuming
the
ID
field is numeric.

SELECT L.ID, L.[Country ID], L.Region,
L.[Dokter info ID], L.[Name Practice/Hospital],
L.[First name], L.[Last name], L.Title, L.[Male/Female],
L.[Language ID], L.specialisme, L.[Country number],
L.Phonenumber, L.Faxnumber, Called.Practician, Called.[Project ID],
[Practician] &
[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
AS
Uttryck1,
[ID] & [Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS
Uttryck2,
IIf([Praction]=[ID],"Don't","Show") AS Uttryck3,
DCount("*","[Test List]","[ID] = " & L.[ID] ) AS TheCount
FROM [lÄKARE LIST] AS L LEFT JOIN Called
ON L.ID = Called.Practician
WHERE Called.[Project
ID]=[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
Or Called.[Project ID] Is Null;

--
Duane Hookom
MS Access MVP
--

Thanks for being so patient with me.

Well, that doesn't seem to be it... Sorry, I should have written
the
full
error message. It says " Circular reference caused by 'Test
List' "

Isn't there something like dcount that can do like this...
Count(all records in Column [ID], from query [Test List], where
the
[ID]
from current record is equal)
all in query [test list]




--
Novice


:

I think the issue is because you create a column named Uttryck2
and
then
use
it in another expression. I avoid this at all cost.

--
Duane Hookom
MS Access MVP
--

I applied it to my existing query sql but I must be doing
something
wrong
(circular referens error message shown).
Here is my SQL for Query [Test List]

SELECT L.ID, L.[Country ID], L.Region, L.[Dokter info ID],
L.[Name
Practice/Hospital], L.[First name], L.[Last name], L.Title,
L.[Male/Female],
L.[Language ID], L.specialisme, L.[Country number],
L.Phonenumber,
L.Faxnumber, Called.Practician, Called.[Project ID],
[Practician]
&
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS
Uttryck1,
[ID]
&
[Forms]![SelectProjectforListtocall]![Kombinationsruta0] AS
Uttryck2,
IIf([Uttryck1]=[Uttryck2],"Don't","Show") AS Uttryck3, (SELECT
Count(*)
FROM
[Test List] q WHERE q.[ID] = L.[ID] ) AS TheCount
FROM [lÄKARE LIST] AS L LEFT JOIN Called ON L.ID =
Called.Practician
WHERE (((Called.[Project
ID])=[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
Or
(Called.[Project ID]) Is Null));


(in case you would wonder:
[Forms]![SelectProjectforListtocall]![Kombinationsruta0]
this is an external factor to eliminate all calls that are not
related
to
this project. It will only keep the ID's of doctors that have
been
called
for
the chosen project and the complete list of doctors. now I
want
to
remove
the
doubles in the same query by counting the recurring ID's)



--
Novice


:

You would enter the select statement into the SQL view of a
query.
Make
sure
you use your table and field names.

--
Duane Hookom
MS Access MVP
--

And where do I put this ? Sorry for my incompetence


SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];





--
Novice


:

Try
SELECT [Test List].*,
(SELECT Count(*)
FROM [Test List] q
WHERE q.[ID] = [Test List].[ID] ) as TheCount
FROM [Test List];

BTW: I don't care for field/column names that are
properties,
functions,
or
sql aggregates (Name, Count)
--
Duane Hookom
MS Access MVP
--

ID Name Project Result COUNT
17 James Test25 Done 2
19 George
2
25 Ben Test25 Cancelled 1
17 James
2
19 George Test25 Done 2
21 Louis
1
07 Ellen
1

ID - Name - Project - Result are taken from tables and
exist.
Count
is
what
I look for. It gives a number for the amount of times an
ID
(name)
appears
in
the query.

I am going to display them in a continuous form where I
will
filter
them
with VBA on click. I just need to get this count so I
can
remove
all
the
ones
that say more than 1 after. To display all names that
haven't
been
called
yet
for the specific project.


--
 

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