Date Range Totals for Logical Fields

S

Susan May

Hi All:

I have a database I import from Outlook, and am keeping a list of all active
recruits. Each week, I need to update 10 logical fields to see how many more
entries were made to each logical question. What is the best way to get my
results. I created a query with these fields that did a sum of all these
filds, but when I try to add to the criteria true for "Active Recruit", it
doesn't work; and if I put a lead date range of "Between #12/1/2007# And
#1/31/2008#", It dosn't like that either. I like the way the sum queries
work - it's one line with all the numbers. How do I add the criteria to make
this work? I've spent days trying to figure this out and need someone's help.

Thanks again.

Susan
 
S

Susan May

Active recuit is a true/false field and Lead date is a short date field
[02/06/2008]

KARL DEWEY said:
What kind of fields are [Active Recruit] and [Lead date]?
--
KARL DEWEY
Build a little - Test a little


Susan May said:
Hi All:

I have a database I import from Outlook, and am keeping a list of all active
recruits. Each week, I need to update 10 logical fields to see how many more
entries were made to each logical question. What is the best way to get my
results. I created a query with these fields that did a sum of all these
filds, but when I try to add to the criteria true for "Active Recruit", it
doesn't work; and if I put a lead date range of "Between #12/1/2007# And
#1/31/2008#", It dosn't like that either. I like the way the sum queries
work - it's one line with all the numbers. How do I add the criteria to make
this work? I've spent days trying to figure this out and need someone's help.

Thanks again.

Susan
 
J

John Spencer

Try adding the fields to the query a second time and change the GROUP BY to
WHERE under the added fields. Then put your criteria there. Remove the
criteria under any field that says GROUP By, Sum, etc.

Using the WHERE filters the data before it is aggregated (Summed, Counted,
Averaged, Grouped, etc)

Applying criteria against a field that is aggregated means that the criteria
is applied AFTER the aggregation. So with a boolean (true/False) field that
is Summed and with the criteria set to TRUE (which is -1), you would be
returning records where the SUM of all the records in the group is equal
to -1. Probably not going to happen very often.


--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
K

KARL DEWEY

Lead date is a short date field
Short date is a format not a datatype. Is it DateTime or Text datatype?
--
KARL DEWEY
Build a little - Test a little


Susan May said:
Active recuit is a true/false field and Lead date is a short date field
[02/06/2008]

KARL DEWEY said:
What kind of fields are [Active Recruit] and [Lead date]?
--
KARL DEWEY
Build a little - Test a little


Susan May said:
Hi All:

I have a database I import from Outlook, and am keeping a list of all active
recruits. Each week, I need to update 10 logical fields to see how many more
entries were made to each logical question. What is the best way to get my
results. I created a query with these fields that did a sum of all these
filds, but when I try to add to the criteria true for "Active Recruit", it
doesn't work; and if I put a lead date range of "Between #12/1/2007# And
#1/31/2008#", It dosn't like that either. I like the way the sum queries
work - it's one line with all the numbers. How do I add the criteria to make
this work? I've spent days trying to figure this out and need someone's help.

Thanks again.

Susan
 
S

Susan May

It is a date/time field. I'm reading John's response. Not quite sure I
understand, but I'm going to try his way unless you have an easier solution.

KARL DEWEY said:
Short date is a format not a datatype. Is it DateTime or Text datatype?
--
KARL DEWEY
Build a little - Test a little


Susan May said:
Active recuit is a true/false field and Lead date is a short date field
[02/06/2008]

KARL DEWEY said:
What kind of fields are [Active Recruit] and [Lead date]?
--
KARL DEWEY
Build a little - Test a little


:

Hi All:

I have a database I import from Outlook, and am keeping a list of all active
recruits. Each week, I need to update 10 logical fields to see how many more
entries were made to each logical question. What is the best way to get my
results. I created a query with these fields that did a sum of all these
filds, but when I try to add to the criteria true for "Active Recruit", it
doesn't work; and if I put a lead date range of "Between #12/1/2007# And
#1/31/2008#", It dosn't like that either. I like the way the sum queries
work - it's one line with all the numbers. How do I add the criteria to make
this work? I've spent days trying to figure this out and need someone's help.

Thanks again.

Susan
 
S

Susan May

John, I'm trying what you said, but the data is coming back incorrect. It's
not counting the right number of leads based on the date criteria. I'm at a
loss.
 
J

John Spencer

Perhaps you could post the SQL statement that is not giving you the expected
results.

Also post one or two rows of data that are "incorrect" and tell us what you
think is "wrong" about the results.

Please copy and post the SQL of your query.

(Possibly unneeded instructions follow)
Open the query
Select View:Sql from the Menu
Select all the text
Copy it
Paste it into the message

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
S

Susan May

Hi John:

Here's the Sql statement:

SELECT DISTINCTROW [Qry_AllDDLeads by Date Range].[Lead Date],
Format$([Qry_AllDDLeads by Date Range].[Lead Date],'mmmm yyyy') AS [Lead Date
By Month], [Qry_AllDDLeads by Date Range].[Signed Up], Sum([Qry_AllDDLeads by
Date Range].[Active Recruit]) AS [Sum Of Active Recruit], Sum([Qry_AllDDLeads
by Date Range].[Info Kit Sent]) AS [Sum Of Info Kit Sent],
Sum([Qry_AllDDLeads by Date Range].[Direct Recruit]) AS [Sum Of Direct
Recruit], Sum([Qry_AllDDLeads by Date Range].[Initial Contact Made]) AS [Sum
Of Initial Contact Made], Sum([Qry_AllDDLeads by Date Range].[DD Invite
Letter Sent]) AS [Sum Of DD Invite Letter Sent], Sum([Qry_AllDDLeads by Date
Range].[Accepted DD Invite]) AS [Sum Of Accepted DD Invite],
Sum([Qry_AllDDLeads by Date Range].[Attended DD Mtg]) AS [Sum Of Attended DD
Mtg], Sum([Qry_AllDDLeads by Date Range].[Follow-up After DD Mtg]) AS [Sum Of
Follow-up After DD Mtg], Sum([Qry_AllDDLeads by Date Range].[Has Contract])
AS [Sum Of Has Contract], Count(*) AS [Count Of Qry_AllDDLeads by Date Range]
FROM [Qry_AllDDLeads by Date Range]
GROUP BY [Qry_AllDDLeads by Date Range].[Lead Date], Format$([Qry_AllDDLeads
by Date Range].[Lead Date],'mmmm yyyy'), [Qry_AllDDLeads by Date
Range].[Signed Up], Year([Qry_AllDDLeads by Date Range].[Lead
Date])*12+DatePart('m',[Qry_AllDDLeads by Date Range].[Lead Date])-1
HAVING ((([Qry_AllDDLeads by Date Range].[Lead Date]) Between #1/28/2008#
And #2/1/2008#));

This creates 2 rows:

Lead Date Lead Date By Month Signed Up Sum Of Active Recruit Sum Of Info Kit
Sent Sum Of Direct Recruit Sum Of Initial Contact Made Sum Of DD Invite
Letter Sent Sum Of Accepted DD Invite Sum Of Attended DD Mtg Sum Of Follow-up
After DD Mtg Sum Of Has Contract Count Of Qry_AllDDLeads by Date Range
1/29/2008 1:00:00 PM January 2008 0 -2 -1 0 0 -1 -1 0 0 0 2
1/30/2008 1:00:00 PM January 2008 0 -8 -8 0 -1 0 0 0 0 0 8

For the period of 12/28/08 - 2/1/08 when I filter the data in Outlook, I
have 2 leads on 1/29; 8 on 1/30; 7 on 1/31 and 1 on 2/1. What's strange is
that in other queries, the total number of active recruits in these queries
total 137 which is what I get when I filter in Outlook. But when I put a
date range in there, it screws up all the data. None of these fields show
the correct number. Here's what I get when I filter in Outlook

Week of Active Info Direct Initial DD
DD
Recruits Kits Sent Recruits Contact Invites
Accepted
Made
1/28/2008 18 17 2 1 1 1

Follow-up # #
After DD Contracts Signed Up
0 0 0

The query is picking up the first two days, but not the rest of the week.
Why is it not competing the date sequence? This is driving me crazy as I
must produce this report every week. Thanks so much for your help.
 
J

John Spencer

Query reformatted for ease of reading

SELECT [Lead Date]
, Format([Lead Date],'mmmm yyyy') AS [Lead Date By Month]
, [Signed Up]
, Sum([Active Recruit]) AS [Sum Of Active Recruit]
, Sum([Info Kit Sent]) AS [Sum Of Info Kit Sent]
, Sum([Direct Recruit]) AS [Sum Of Direct Recruit]
, Sum([Initial Contact Made]) AS [Sum Of Initial Contact Made]
, Sum([DD Invite Letter Sent]) AS [Sum Of DD Invite Letter Sent]
, Sum([Accepted DD Invite]) AS [Sum Of Accepted DD Invite]
, Sum([Attended DD Mtg]) AS [Sum Of Attended DD Mtg]
, Sum([Follow-up After DD Mtg]) AS [Sum Of Follow-up After DD Mtg]
, Sum([Has Contract]) AS [Sum Of Has Contract]
, Count(*) AS [Count Of Qry_AllDDLeads by Date Range]
FROM [Qry_AllDDLeads by Date Range]

WHERE [Lead Date] Between #1/28/2008# And #2/1/2008#

GROUP BY [Lead Date]
, Format([Lead Date],'mmmm yyyy')
, [Signed Up]
, Year([Lead Date])*12+DatePart('m',[Lead Date])-1

Your query should return information for the period 1/28 up to midnight of
2/1 Basically for records where Lead Date runs from 1/28 to 1/31. IF you
want records for the Feb 1 also, then you need to change the where clause to
WHERE [Lead Date] >= #1/28/2008# And [Lead Date] < #2/2/2008#

I don't have any idea what you are attempting to accomplish with the
expression
, Year([Lead Date])*12+DatePart('m',[Lead Date])-1
That looks as if it is useless to me.

Do you have records for each of the dates 1/28 to 2/1? This query is only
going to work on those records. If you have no record for 1/31 then there
will be row returned for that date.


--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
S

Susan May

John: For this date range, I have

2 leads on 1/29
8 leads on 1/30
7 leads on 1/31
1 lead on 2/1

I put the where clause under the Group by Lead Date, and it came back with
36 leads. Look at the lead dates -- why is it going back to 12/1/07 and not
going thru 2/1?

Lead Date
12/1/2007 1:00:00 PM
12/2/2007 1:00:00 PM
12/3/2007 1:00:00 PM
12/4/2007 1:00:00 PM
12/5/2007 1:00:00 PM
12/6/2007 1:00:00 PM
12/10/2007 1:00:00 PM
12/11/2007 1:00:00 PM
12/12/2007 1:00:00 PM
12/13/2007 1:00:00 PM
12/15/2007 1:00:00 PM
12/16/2007 1:00:00 PM
12/18/2007 1:00:00 PM
12/19/2007 1:00:00 PM
12/20/2007 1:00:00 PM
12/21/2007 1:00:00 PM
12/25/2007 1:00:00 PM
12/26/2007 1:00:00 PM
12/27/2007 1:00:00 PM
12/28/2007 1:00:00 PM
12/29/2007 1:00:00 PM
1/1/2008 1:00:00 PM
1/1/2008 7:08:00 PM
1/2/2008 1:00:00 PM
1/4/2008 1:00:00 PM
1/6/2008 1:00:00 PM
1/7/2008 1:00:00 PM
1/8/2008 1:00:00 PM
1/10/2008 1:00:00 PM
1/11/2008 5:07:00 PM
1/14/2008 1:00:00 PM
1/15/2008 1:00:00 PM
1/17/2008 1:00:00 PM
1/25/2008 1:00:00 PM
1/29/2008 1:00:00 PM
1/30/2008 1:00:00 PM

John Spencer said:
Query reformatted for ease of reading

SELECT [Lead Date]
, Format([Lead Date],'mmmm yyyy') AS [Lead Date By Month]
, [Signed Up]
, Sum([Active Recruit]) AS [Sum Of Active Recruit]
, Sum([Info Kit Sent]) AS [Sum Of Info Kit Sent]
, Sum([Direct Recruit]) AS [Sum Of Direct Recruit]
, Sum([Initial Contact Made]) AS [Sum Of Initial Contact Made]
, Sum([DD Invite Letter Sent]) AS [Sum Of DD Invite Letter Sent]
, Sum([Accepted DD Invite]) AS [Sum Of Accepted DD Invite]
, Sum([Attended DD Mtg]) AS [Sum Of Attended DD Mtg]
, Sum([Follow-up After DD Mtg]) AS [Sum Of Follow-up After DD Mtg]
, Sum([Has Contract]) AS [Sum Of Has Contract]
, Count(*) AS [Count Of Qry_AllDDLeads by Date Range]
FROM [Qry_AllDDLeads by Date Range]

WHERE [Lead Date] Between #1/28/2008# And #2/1/2008#

GROUP BY [Lead Date]
, Format([Lead Date],'mmmm yyyy')
, [Signed Up]
, Year([Lead Date])*12+DatePart('m',[Lead Date])-1

Your query should return information for the period 1/28 up to midnight of
2/1 Basically for records where Lead Date runs from 1/28 to 1/31. IF you
want records for the Feb 1 also, then you need to change the where clause to
WHERE [Lead Date] >= #1/28/2008# And [Lead Date] < #2/2/2008#

I don't have any idea what you are attempting to accomplish with the
expression
, Year([Lead Date])*12+DatePart('m',[Lead Date])-1
That looks as if it is useless to me.

Do you have records for each of the dates 1/28 to 2/1? This query is only
going to work on those records. If you have no record for 1/31 then there
will be row returned for that date.


--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Susan May said:
Hi John:

Here's the Sql statement:
SNIP

This creates 2 rows:

Lead Date Lead Date By Month Signed Up Sum Of Active Recruit Sum Of Info
Kit
Sent Sum Of Direct Recruit Sum Of Initial Contact Made Sum Of DD Invite
Letter Sent Sum Of Accepted DD Invite Sum Of Attended DD Mtg Sum Of
Follow-up
After DD Mtg Sum Of Has Contract Count Of Qry_AllDDLeads by Date Range
1/29/2008 1:00:00 PM January 2008 0 -2 -1 0 0 -1 -1 0 0 0 2
1/30/2008 1:00:00 PM January 2008 0 -8 -8 0 -1 0 0 0 0 0 8

For the period of 12/28/08 - 2/1/08 when I filter the data in Outlook, I
have 2 leads on 1/29; 8 on 1/30; 7 on 1/31 and 1 on 2/1. What's strange
is
that in other queries, the total number of active recruits in these
queries
total 137 which is what I get when I filter in Outlook. But when I put a
date range in there, it screws up all the data. None of these fields show
the correct number. Here's what I get when I filter in Outlook

Week of Active Info Direct Initial DD
DD
Recruits Kits Sent Recruits Contact Invites
Accepted
Made
1/28/2008 18 17 2 1 1 1

Follow-up # #
After DD Contracts Signed Up
0 0 0

The query is picking up the first two days, but not the rest of the week.
Why is it not competing the date sequence? This is driving me crazy as I
must produce this report every week. Thanks so much for your help.
 
J

John Spencer

I have no idea why it is going back to 12/1/2007. It is missing the 2/1
record because the DateTime 2/1/2008 01:00:00 PM is after 2/1/2008 00:00:00
AM IF you wanted that record you would need to change the where clause to
read
WHERE [Lead Date] >=#1/28/2008# And [Lead Date] < #2/2/2008#

Is there any chance that your Lead Time field is not a date time field but
is a text field that contains a string that looks like a date and time?
--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Susan May said:
John: For this date range, I have

2 leads on 1/29
8 leads on 1/30
7 leads on 1/31
1 lead on 2/1

I put the where clause under the Group by Lead Date, and it came back with
36 leads. Look at the lead dates -- why is it going back to 12/1/07 and
not
going thru 2/1?

Lead Date
12/1/2007 1:00:00 PM
12/2/2007 1:00:00 PM
12/3/2007 1:00:00 PM
12/4/2007 1:00:00 PM
12/5/2007 1:00:00 PM
12/6/2007 1:00:00 PM
12/10/2007 1:00:00 PM
12/11/2007 1:00:00 PM
12/12/2007 1:00:00 PM
12/13/2007 1:00:00 PM
12/15/2007 1:00:00 PM
12/16/2007 1:00:00 PM
12/18/2007 1:00:00 PM
12/19/2007 1:00:00 PM
12/20/2007 1:00:00 PM
12/21/2007 1:00:00 PM
12/25/2007 1:00:00 PM
12/26/2007 1:00:00 PM
12/27/2007 1:00:00 PM
12/28/2007 1:00:00 PM
12/29/2007 1:00:00 PM
1/1/2008 1:00:00 PM
1/1/2008 7:08:00 PM
1/2/2008 1:00:00 PM
1/4/2008 1:00:00 PM
1/6/2008 1:00:00 PM
1/7/2008 1:00:00 PM
1/8/2008 1:00:00 PM
1/10/2008 1:00:00 PM
1/11/2008 5:07:00 PM
1/14/2008 1:00:00 PM
1/15/2008 1:00:00 PM
1/17/2008 1:00:00 PM
1/25/2008 1:00:00 PM
1/29/2008 1:00:00 PM
1/30/2008 1:00:00 PM

John Spencer said:
Query reformatted for ease of reading

SELECT [Lead Date]
, Format([Lead Date],'mmmm yyyy') AS [Lead Date By Month]
, [Signed Up]
, Sum([Active Recruit]) AS [Sum Of Active Recruit]
, Sum([Info Kit Sent]) AS [Sum Of Info Kit Sent]
, Sum([Direct Recruit]) AS [Sum Of Direct Recruit]
, Sum([Initial Contact Made]) AS [Sum Of Initial Contact Made]
, Sum([DD Invite Letter Sent]) AS [Sum Of DD Invite Letter Sent]
, Sum([Accepted DD Invite]) AS [Sum Of Accepted DD Invite]
, Sum([Attended DD Mtg]) AS [Sum Of Attended DD Mtg]
, Sum([Follow-up After DD Mtg]) AS [Sum Of Follow-up After DD Mtg]
, Sum([Has Contract]) AS [Sum Of Has Contract]
, Count(*) AS [Count Of Qry_AllDDLeads by Date Range]
FROM [Qry_AllDDLeads by Date Range]

WHERE [Lead Date] Between #1/28/2008# And #2/1/2008#

GROUP BY [Lead Date]
, Format([Lead Date],'mmmm yyyy')
, [Signed Up]
, Year([Lead Date])*12+DatePart('m',[Lead Date])-1

Your query should return information for the period 1/28 up to midnight
of
2/1 Basically for records where Lead Date runs from 1/28 to 1/31. IF
you
want records for the Feb 1 also, then you need to change the where clause
to
WHERE [Lead Date] >= #1/28/2008# And [Lead Date] < #2/2/2008#

I don't have any idea what you are attempting to accomplish with the
expression
, Year([Lead Date])*12+DatePart('m',[Lead Date])-1
That looks as if it is useless to me.

Do you have records for each of the dates 1/28 to 2/1? This query is
only
going to work on those records. If you have no record for 1/31 then
there
will be row returned for that date.


--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Susan May said:
Hi John:

Here's the Sql statement:
SNIP

This creates 2 rows:

Lead Date Lead Date By Month Signed Up Sum Of Active Recruit Sum Of
Info
Kit
Sent Sum Of Direct Recruit Sum Of Initial Contact Made Sum Of DD Invite
Letter Sent Sum Of Accepted DD Invite Sum Of Attended DD Mtg Sum Of
Follow-up
After DD Mtg Sum Of Has Contract Count Of Qry_AllDDLeads by Date Range
1/29/2008 1:00:00 PM January 2008 0 -2 -1 0 0 -1 -1 0 0 0 2
1/30/2008 1:00:00 PM January 2008 0 -8 -8 0 -1 0 0 0 0 0 8

For the period of 12/28/08 - 2/1/08 when I filter the data in Outlook,
I
have 2 leads on 1/29; 8 on 1/30; 7 on 1/31 and 1 on 2/1. What's
strange
is
that in other queries, the total number of active recruits in these
queries
total 137 which is what I get when I filter in Outlook. But when I put
a
date range in there, it screws up all the data. None of these fields
show
the correct number. Here's what I get when I filter in Outlook

Week of Active Info Direct Initial DD
DD
Recruits Kits Sent Recruits Contact Invites
Accepted
Made
1/28/2008 18 17 2 1 1 1

Follow-up # #
After DD Contracts Signed Up
0 0 0

The query is picking up the first two days, but not the rest of the
week.
Why is it not competing the date sequence? This is driving me crazy as
I
must produce this report every week. Thanks so much for your help.

:

Perhaps you could post the SQL statement that is not giving you the
expected
results.

Also post one or two rows of data that are "incorrect" and tell us
what
you
think is "wrong" about the results.

Please copy and post the SQL of your query.

(Possibly unneeded instructions follow)
Open the query
Select View:Sql from the Menu
Select all the text
Copy it
Paste it into the message

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..


John, I'm trying what you said, but the data is coming back
incorrect.
It's
not counting the right number of leads based on the date criteria.
I'm
at
a
loss.

:

Try adding the fields to the query a second time and change the
GROUP
BY
to
WHERE under the added fields. Then put your criteria there.
Remove
the
criteria under any field that says GROUP By, Sum, etc.

Using the WHERE filters the data before it is aggregated (Summed,
Counted,
Averaged, Grouped, etc)

Applying criteria against a field that is aggregated means that the
criteria
is applied AFTER the aggregation. So with a boolean (true/False)
field
that
is Summed and with the criteria set to TRUE (which is -1), you
would
be
returning records where the SUM of all the records in the group is
equal
to -1. Probably not going to happen very often.


--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Hi All:

I have a database I import from Outlook, and am keeping a list of
all
active
recruits. Each week, I need to update 10 logical fields to see
how
many
more
entries were made to each logical question. What is the best way
to
get
my
results. I created a query with these fields that did a sum of
all
these
filds, but when I try to add to the criteria true for "Active
Recruit",
it
doesn't work; and if I put a lead date range of "Between
#12/1/2007#
And
#1/31/2008#", It dosn't like that either. I like the way the sum
queries
work - it's one line with all the numbers. How do I add the
criteria
to
make
this work? I've spent days trying to figure this out and need
someone's
help.

Thanks again.

Susan
 
S

Susan May

John- the field is a true date/time field. I just rechecked the Where clause
and I have it exactly as you instructed. Still get records starting on
12/1/07 and ending on 1/30/08. This just doesn't make any sense. I just
change the structure of the date field to a short date and that didn't make
the query run any different. Access should be logical and this is not
logical. Anybody have any other ideas where I can get weekly leads by this
date field? Why when you creat this query and you ask it to sum all the
Yes/No fields, does it not have an option for weekly? It has date/time,
month, quarter, year - not weekly?

Frustrated Susan!



John Spencer said:
I have no idea why it is going back to 12/1/2007. It is missing the 2/1
record because the DateTime 2/1/2008 01:00:00 PM is after 2/1/2008 00:00:00
AM IF you wanted that record you would need to change the where clause to
read
WHERE [Lead Date] >=#1/28/2008# And [Lead Date] < #2/2/2008#

Is there any chance that your Lead Time field is not a date time field but
is a text field that contains a string that looks like a date and time?
--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Susan May said:
John: For this date range, I have

2 leads on 1/29
8 leads on 1/30
7 leads on 1/31
1 lead on 2/1

I put the where clause under the Group by Lead Date, and it came back with
36 leads. Look at the lead dates -- why is it going back to 12/1/07 and
not
going thru 2/1?

Lead Date
12/1/2007 1:00:00 PM
12/2/2007 1:00:00 PM
12/3/2007 1:00:00 PM
12/4/2007 1:00:00 PM
12/5/2007 1:00:00 PM
12/6/2007 1:00:00 PM
12/10/2007 1:00:00 PM
12/11/2007 1:00:00 PM
12/12/2007 1:00:00 PM
12/13/2007 1:00:00 PM
12/15/2007 1:00:00 PM
12/16/2007 1:00:00 PM
12/18/2007 1:00:00 PM
12/19/2007 1:00:00 PM
12/20/2007 1:00:00 PM
12/21/2007 1:00:00 PM
12/25/2007 1:00:00 PM
12/26/2007 1:00:00 PM
12/27/2007 1:00:00 PM
12/28/2007 1:00:00 PM
12/29/2007 1:00:00 PM
1/1/2008 1:00:00 PM
1/1/2008 7:08:00 PM
1/2/2008 1:00:00 PM
1/4/2008 1:00:00 PM
1/6/2008 1:00:00 PM
1/7/2008 1:00:00 PM
1/8/2008 1:00:00 PM
1/10/2008 1:00:00 PM
1/11/2008 5:07:00 PM
1/14/2008 1:00:00 PM
1/15/2008 1:00:00 PM
1/17/2008 1:00:00 PM
1/25/2008 1:00:00 PM
1/29/2008 1:00:00 PM
1/30/2008 1:00:00 PM

John Spencer said:
Query reformatted for ease of reading

SELECT [Lead Date]
, Format([Lead Date],'mmmm yyyy') AS [Lead Date By Month]
, [Signed Up]
, Sum([Active Recruit]) AS [Sum Of Active Recruit]
, Sum([Info Kit Sent]) AS [Sum Of Info Kit Sent]
, Sum([Direct Recruit]) AS [Sum Of Direct Recruit]
, Sum([Initial Contact Made]) AS [Sum Of Initial Contact Made]
, Sum([DD Invite Letter Sent]) AS [Sum Of DD Invite Letter Sent]
, Sum([Accepted DD Invite]) AS [Sum Of Accepted DD Invite]
, Sum([Attended DD Mtg]) AS [Sum Of Attended DD Mtg]
, Sum([Follow-up After DD Mtg]) AS [Sum Of Follow-up After DD Mtg]
, Sum([Has Contract]) AS [Sum Of Has Contract]
, Count(*) AS [Count Of Qry_AllDDLeads by Date Range]
FROM [Qry_AllDDLeads by Date Range]

WHERE [Lead Date] Between #1/28/2008# And #2/1/2008#

GROUP BY [Lead Date]
, Format([Lead Date],'mmmm yyyy')
, [Signed Up]
, Year([Lead Date])*12+DatePart('m',[Lead Date])-1

Your query should return information for the period 1/28 up to midnight
of
2/1 Basically for records where Lead Date runs from 1/28 to 1/31. IF
you
want records for the Feb 1 also, then you need to change the where clause
to
WHERE [Lead Date] >= #1/28/2008# And [Lead Date] < #2/2/2008#

I don't have any idea what you are attempting to accomplish with the
expression
, Year([Lead Date])*12+DatePart('m',[Lead Date])-1
That looks as if it is useless to me.

Do you have records for each of the dates 1/28 to 2/1? This query is
only
going to work on those records. If you have no record for 1/31 then
there
will be row returned for that date.


--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..


Hi John:

Here's the Sql statement:
SNIP

This creates 2 rows:

Lead Date Lead Date By Month Signed Up Sum Of Active Recruit Sum Of
Info
Kit
Sent Sum Of Direct Recruit Sum Of Initial Contact Made Sum Of DD Invite
Letter Sent Sum Of Accepted DD Invite Sum Of Attended DD Mtg Sum Of
Follow-up
After DD Mtg Sum Of Has Contract Count Of Qry_AllDDLeads by Date Range
1/29/2008 1:00:00 PM January 2008 0 -2 -1 0 0 -1 -1 0 0 0 2
1/30/2008 1:00:00 PM January 2008 0 -8 -8 0 -1 0 0 0 0 0 8

For the period of 12/28/08 - 2/1/08 when I filter the data in Outlook,
I
have 2 leads on 1/29; 8 on 1/30; 7 on 1/31 and 1 on 2/1. What's
strange
is
that in other queries, the total number of active recruits in these
queries
total 137 which is what I get when I filter in Outlook. But when I put
a
date range in there, it screws up all the data. None of these fields
show
the correct number. Here's what I get when I filter in Outlook

Week of Active Info Direct Initial DD
DD
Recruits Kits Sent Recruits Contact Invites
Accepted
Made
1/28/2008 18 17 2 1 1 1

Follow-up # #
After DD Contracts Signed Up
0 0 0

The query is picking up the first two days, but not the rest of the
week.
Why is it not competing the date sequence? This is driving me crazy as
I
must produce this report every week. Thanks so much for your help.

:

Perhaps you could post the SQL statement that is not giving you the
expected
results.

Also post one or two rows of data that are "incorrect" and tell us
what
you
think is "wrong" about the results.

Please copy and post the SQL of your query.

(Possibly unneeded instructions follow)
Open the query
Select View:Sql from the Menu
Select all the text
Copy it
Paste it into the message

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..


John, I'm trying what you said, but the data is coming back
incorrect.
It's
not counting the right number of leads based on the date criteria.
I'm
at
a
loss.

:

Try adding the fields to the query a second time and change the
GROUP
BY
to
WHERE under the added fields. Then put your criteria there.
Remove
the
criteria under any field that says GROUP By, Sum, etc.

Using the WHERE filters the data before it is aggregated (Summed,
Counted,
Averaged, Grouped, etc)

Applying criteria against a field that is aggregated means that the
criteria
is applied AFTER the aggregation. So with a boolean (true/False)
field
that
is Summed and with the criteria set to TRUE (which is -1), you
would
be
returning records where the SUM of all the records in the group is
equal
to -1. Probably not going to happen very often.


--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Hi All:

I have a database I import from Outlook, and am keeping a list of
all
active
recruits. Each week, I need to update 10 logical fields to see
how
many
more
entries were made to each logical question. What is the best way
to
get
my
results. I created a query with these fields that did a sum of
all
these
filds, but when I try to add to the criteria true for "Active
Recruit",
it
doesn't work; and if I put a lead date range of "Between
#12/1/2007#
And
#1/31/2008#", It dosn't like that either. I like the way the sum
queries
work - it's one line with all the numbers. How do I add the
criteria
to
make
this work? I've spent days trying to figure this out and need
someone's
help.

Thanks again.

Susan
 
G

Gary Walter

Hi Susan,

PMFJI

You keep insisting it is a "true date/time field,"
yet your results are "logical" if field is *string*.

Easy test...

SELECT
[Lead Date],
TypeName([Lead Date]) As ActualType
FROM
[Qry_AllDDLeads by Date Range];

good luck,

gary


Susan May said:
John- the field is a true date/time field. I just rechecked the Where
clause
and I have it exactly as you instructed. Still get records starting on
12/1/07 and ending on 1/30/08. This just doesn't make any sense. I just
change the structure of the date field to a short date and that didn't
make
the query run any different. Access should be logical and this is not
logical. Anybody have any other ideas where I can get weekly leads by
this
date field? Why when you creat this query and you ask it to sum all the
Yes/No fields, does it not have an option for weekly? It has date/time,
month, quarter, year - not weekly?

Frustrated Susan!



John Spencer said:
I have no idea why it is going back to 12/1/2007. It is missing the 2/1
record because the DateTime 2/1/2008 01:00:00 PM is after 2/1/2008
00:00:00
AM IF you wanted that record you would need to change the where clause
to
read
WHERE [Lead Date] >=#1/28/2008# And [Lead Date] < #2/2/2008#

Is there any chance that your Lead Time field is not a date time field
but
is a text field that contains a string that looks like a date and time?
--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Susan May said:
John: For this date range, I have

2 leads on 1/29
8 leads on 1/30
7 leads on 1/31
1 lead on 2/1

I put the where clause under the Group by Lead Date, and it came back
with
36 leads. Look at the lead dates -- why is it going back to 12/1/07
and
not
going thru 2/1?

Lead Date
12/1/2007 1:00:00 PM
12/2/2007 1:00:00 PM
12/3/2007 1:00:00 PM
12/4/2007 1:00:00 PM
12/5/2007 1:00:00 PM
12/6/2007 1:00:00 PM
12/10/2007 1:00:00 PM
12/11/2007 1:00:00 PM
12/12/2007 1:00:00 PM
12/13/2007 1:00:00 PM
12/15/2007 1:00:00 PM
12/16/2007 1:00:00 PM
12/18/2007 1:00:00 PM
12/19/2007 1:00:00 PM
12/20/2007 1:00:00 PM
12/21/2007 1:00:00 PM
12/25/2007 1:00:00 PM
12/26/2007 1:00:00 PM
12/27/2007 1:00:00 PM
12/28/2007 1:00:00 PM
12/29/2007 1:00:00 PM
1/1/2008 1:00:00 PM
1/1/2008 7:08:00 PM
1/2/2008 1:00:00 PM
1/4/2008 1:00:00 PM
1/6/2008 1:00:00 PM
1/7/2008 1:00:00 PM
1/8/2008 1:00:00 PM
1/10/2008 1:00:00 PM
1/11/2008 5:07:00 PM
1/14/2008 1:00:00 PM
1/15/2008 1:00:00 PM
1/17/2008 1:00:00 PM
1/25/2008 1:00:00 PM
1/29/2008 1:00:00 PM
1/30/2008 1:00:00 PM

:

Query reformatted for ease of reading

SELECT [Lead Date]
, Format([Lead Date],'mmmm yyyy') AS [Lead Date By Month]
, [Signed Up]
, Sum([Active Recruit]) AS [Sum Of Active Recruit]
, Sum([Info Kit Sent]) AS [Sum Of Info Kit Sent]
, Sum([Direct Recruit]) AS [Sum Of Direct Recruit]
, Sum([Initial Contact Made]) AS [Sum Of Initial Contact Made]
, Sum([DD Invite Letter Sent]) AS [Sum Of DD Invite Letter Sent]
, Sum([Accepted DD Invite]) AS [Sum Of Accepted DD Invite]
, Sum([Attended DD Mtg]) AS [Sum Of Attended DD Mtg]
, Sum([Follow-up After DD Mtg]) AS [Sum Of Follow-up After DD Mtg]
, Sum([Has Contract]) AS [Sum Of Has Contract]
, Count(*) AS [Count Of Qry_AllDDLeads by Date Range]
FROM [Qry_AllDDLeads by Date Range]

WHERE [Lead Date] Between #1/28/2008# And #2/1/2008#

GROUP BY [Lead Date]
, Format([Lead Date],'mmmm yyyy')
, [Signed Up]
, Year([Lead Date])*12+DatePart('m',[Lead Date])-1

Your query should return information for the period 1/28 up to
midnight
of
2/1 Basically for records where Lead Date runs from 1/28 to 1/31. IF
you
want records for the Feb 1 also, then you need to change the where
clause
to
WHERE [Lead Date] >= #1/28/2008# And [Lead Date] < #2/2/2008#

I don't have any idea what you are attempting to accomplish with the
expression
, Year([Lead Date])*12+DatePart('m',[Lead Date])-1
That looks as if it is useless to me.

Do you have records for each of the dates 1/28 to 2/1? This query is
only
going to work on those records. If you have no record for 1/31 then
there
will be row returned for that date.


--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..


Hi John:

Here's the Sql statement:
SNIP

This creates 2 rows:

Lead Date Lead Date By Month Signed Up Sum Of Active Recruit Sum Of
Info
Kit
Sent Sum Of Direct Recruit Sum Of Initial Contact Made Sum Of DD
Invite
Letter Sent Sum Of Accepted DD Invite Sum Of Attended DD Mtg Sum Of
Follow-up
After DD Mtg Sum Of Has Contract Count Of Qry_AllDDLeads by Date
Range
1/29/2008 1:00:00 PM January 2008 0 -2 -1 0 0 -1 -1 0 0 0 2
1/30/2008 1:00:00 PM January 2008 0 -8 -8 0 -1 0 0 0 0 0 8

For the period of 12/28/08 - 2/1/08 when I filter the data in
Outlook,
I
have 2 leads on 1/29; 8 on 1/30; 7 on 1/31 and 1 on 2/1. What's
strange
is
that in other queries, the total number of active recruits in these
queries
total 137 which is what I get when I filter in Outlook. But when I
put
a
date range in there, it screws up all the data. None of these
fields
show
the correct number. Here's what I get when I filter in Outlook

Week of Active Info Direct Initial DD
DD
Recruits Kits Sent Recruits Contact Invites
Accepted
Made
1/28/2008 18 17 2 1 1 1

Follow-up # #
After DD Contracts Signed Up
0 0 0

The query is picking up the first two days, but not the rest of the
week.
Why is it not competing the date sequence? This is driving me crazy
as
I
must produce this report every week. Thanks so much for your help.

:

Perhaps you could post the SQL statement that is not giving you the
expected
results.

Also post one or two rows of data that are "incorrect" and tell us
what
you
think is "wrong" about the results.

Please copy and post the SQL of your query.

(Possibly unneeded instructions follow)
Open the query
Select View:Sql from the Menu
Select all the text
Copy it
Paste it into the message

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..


John, I'm trying what you said, but the data is coming back
incorrect.
It's
not counting the right number of leads based on the date
criteria.
I'm
at
a
loss.

:

Try adding the fields to the query a second time and change the
GROUP
BY
to
WHERE under the added fields. Then put your criteria there.
Remove
the
criteria under any field that says GROUP By, Sum, etc.

Using the WHERE filters the data before it is aggregated
(Summed,
Counted,
Averaged, Grouped, etc)

Applying criteria against a field that is aggregated means that
the
criteria
is applied AFTER the aggregation. So with a boolean
(true/False)
field
that
is Summed and with the criteria set to TRUE (which is -1), you
would
be
returning records where the SUM of all the records in the group
is
equal
to -1. Probably not going to happen very often.


--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

message
Hi All:

I have a database I import from Outlook, and am keeping a list
of
all
active
recruits. Each week, I need to update 10 logical fields to
see
how
many
more
entries were made to each logical question. What is the best
way
to
get
my
results. I created a query with these fields that did a sum
of
all
these
filds, but when I try to add to the criteria true for "Active
Recruit",
it
doesn't work; and if I put a lead date range of "Between
#12/1/2007#
And
#1/31/2008#", It dosn't like that either. I like the way the
sum
queries
work - it's one line with all the numbers. How do I add the
criteria
to
make
this work? I've spent days trying to figure this out and need
someone's
help.

Thanks again.

Susan
 
G

Gary Walter

Gary Walter said:
You keep insisting it is a "true date/time field,"
yet your results are "logical" if field is *string*.

Easy test...

SELECT
[Lead Date],
TypeName([Lead Date]) As ActualType
FROM
[Qry_AllDDLeads by Date Range];


just to show example of why "logical"....

here be how *string dates* would sort

01/01/2008
01/02/2008
01/03/2008
01/04/2008
01/05/2008
01/06/2008
01/07/2008
01/08/2008
01/09/2008
01/10/2008
01/11/2008
01/12/2008
01/13/2008
01/14/2008
01/15/2008
01/16/2008
01/17/2008
01/18/2008
01/19/2008
01/20/2008
01/21/2008
01/22/2008
01/23/2008
01/24/2008
01/25/2008
01/26/2008
01/27/2008
01/28/2008
01/29/2008
01/30/2008
01/31/2008
02/01/2008
02/02/2008 <-- "1/28/2008" would sort after this string
12/01/2007 <-- and before this string
12/02/2007
12/03/2007
12/04/2007
12/05/2007
12/06/2007
12/07/2007
12/08/2007
12/09/2007
12/10/2007
12/11/2007
12/12/2007
12/13/2007
12/14/2007
12/15/2007
12/16/2007
12/17/2007
12/18/2007
12/19/2007
12/20/2007
12/21/2007
12/22/2007
12/23/2007
12/24/2007
12/25/2007
12/26/2007
12/27/2007
12/28/2007
12/29/2007
12/30/2007
12/31/2007
<-- "2/1/2008" would sort after last string

anytime you "format" a true date/time,
it becomes a string (which may be what
happened in [Qry_AllDDLeads by Date Range]?

good luck,

gary
 
S

Susan May

Hi Gary:

I don't know much about select clauses and subqueries, so I tried putting
this in

Select[Lead Date]), TypeName([Lead Date]) As ActualType From [Qry_AllDDLeads
by Date Range] for [Lead Date] between #2/4/2008# and #2/8/2008#) and got the
error message "Check the subquery's syntax and enclose the subquery in
parenthesis. I've tried putting parenthesis in several locations and get
different error messages. What am I doing wrong?

Many thanks for your help.

Gary Walter said:
Gary Walter said:
You keep insisting it is a "true date/time field,"
yet your results are "logical" if field is *string*.

Easy test...

SELECT
[Lead Date],
TypeName([Lead Date]) As ActualType
FROM
[Qry_AllDDLeads by Date Range];


just to show example of why "logical"....

here be how *string dates* would sort

01/01/2008
01/02/2008
01/03/2008
01/04/2008
01/05/2008
01/06/2008
01/07/2008
01/08/2008
01/09/2008
01/10/2008
01/11/2008
01/12/2008
01/13/2008
01/14/2008
01/15/2008
01/16/2008
01/17/2008
01/18/2008
01/19/2008
01/20/2008
01/21/2008
01/22/2008
01/23/2008
01/24/2008
01/25/2008
01/26/2008
01/27/2008
01/28/2008
01/29/2008
01/30/2008
01/31/2008
02/01/2008
02/02/2008 <-- "1/28/2008" would sort after this string
12/01/2007 <-- and before this string
12/02/2007
12/03/2007
12/04/2007
12/05/2007
12/06/2007
12/07/2007
12/08/2007
12/09/2007
12/10/2007
12/11/2007
12/12/2007
12/13/2007
12/14/2007
12/15/2007
12/16/2007
12/17/2007
12/18/2007
12/19/2007
12/20/2007
12/21/2007
12/22/2007
12/23/2007
12/24/2007
12/25/2007
12/26/2007
12/27/2007
12/28/2007
12/29/2007
12/30/2007
12/31/2007
<-- "2/1/2008" would sort after last string

anytime you "format" a true date/time,
it becomes a string (which may be what
happened in [Qry_AllDDLeads by Date Range]?

good luck,

gary
 
G

Gary Walter

Hi Susan,

I'm sorry if I was not clear, but the test query

SELECT
[Lead Date],
TypeName([Lead Date]) As ActualType
FROM
[Qry_AllDDLeads by Date Range];

was meant to be a stand-alone query to
verify the actual type of the query field

[Qry_AllDDLeads by Date Range].[Lead Date]

my guess was that result of the above query
would show "String" in the ActualType column
based on how the filtering was (not) working for you.

You have provided the SQL for the query
*based on* [Qry_AllDDLeads by Date Range],
but it may help if you provide SQL for this
base query as well.

Are you setting a format of [Lead Date] in the
column "Properties" of either query?

I wonder if that is what you meant by:

" I just change the structure of the date field to a short date
and that didn't make the query run any different."

Again...any time you *format* a pure Date/Time,
it becomes a STRING (and so will sort/filter as
a string, instead of as a Date/Time).

///////////////////////////////////////////
Another thing that may be at first hard to understand
designing a GROUP BY query in the grid ...

"I put the where clause under the Group by Lead Date"

Field: [Lead Date]
Table: [Qry_AllDDLeads by Date Range]
Total: GROUP BY
Sort:
Show:
Criteria: BETWEEN #1/28/2008# AND #2/1/2008#
or:

That will produce a HAVING clause. That was not
why the "dates" were filtering as strings, but you will
learn that HAVING can be inefficient because it
does the filtering only after all the groups have been
made and the aggregating has occurred.

To create a WHERE clause, you would need to
add [Lead Date] a second time to grid,
change the GROUP BY to WHERE,
and put your filter dates in that column's
Criteria row (not under original GROUP BY column):


Field: [Lead Date]
Table: [Qry_AllDDLeads by Date Range]
Total: WHERE
Sort:
Show:
Criteria: BETWEEN #1/28/2008# AND #2/1/2008#
or:

the above filtering will happen *before* groups
are created and aggregation occurs.

Sometimes the difference between applying the filter
before grouping (WHERE) and applying the filter
after grouping (HAVING) will also effect the results
you get for your aggregate(s) like SUM(...).

///////////////////////////
Another note if you are using Access 2000 or later,
"DISTINCTROW" really is designed for queries
that involve more than one "table source."

Plus, in a GROUP BY query, your "group" should do the
work of creating distinct rows.

/////////////////////////////

if you are tired and frustrated, sometimes a "little success"
can help you out of the "gumption traps."

if our multiple guesses were correct (you have somehow formatted
[Lead Date] into a string, you might copy the following into a new
query just to see some possible "success."

SELECT
Q.[Lead Date] AS LeadDate,
Format$(Q.[Lead Date],'mmmm yyyy') AS LeadDateByMonth,
Q.[Signed Up] AS SignedUp,
Sum(Q.[Active Recruit]) AS SumOfActiveRecruit,
Sum(Q.[Info Kit Sent]) AS SumOfInfoKitSent,
Sum(Q.[Direct Recruit]) AS SumOfDirectRecruit,
Sum(Q.[Initial Contact Made]) AS SumOfInitialContactMade,
Sum(Q.[DD Invite Letter Sent]) AS SumOfDDInviteLetterSent,
Sum(Q.[Accepted DD Invite]) AS SumOfAcceptedDDInvite,
Sum(Q.[Attended DD Mtg]) AS SumOfAttendedDDMtg,
Sum(Q.[Follow-up After DD Mtg]) AS SumOfFollowUpAfterDDMtg,
Sum(Q.[Has Contract]) AS SumOfHasContract,
Count(*) AS LeadCnt
FROM [Qry_AllDDLeads by Date Range] AS Q
GROUP BY
Q.[Lead Date],
Format$(Q.[Lead Date],'mmmm yyyy'),
Q.[Signed Up]
WHERE
CDate(NZ(Q.[Lead Date],#9/9/9999#))
Between
#1/28/2008#
And
#2/1/2008#;

It (very inefficiently) changes [Lead Date] back to a Date/Time
before applying date range in WHERE clause.

If I have not done something stupid (my typing sucks...),
I'd be interested in the results you get....

good luck,

gary


Susan May said:
I don't know much about select clauses and subqueries, so I tried
putting this in
Select[Lead Date]), TypeName([Lead Date]) As ActualType From
[Qry_AllDDLeads by Date Range] for [Lead Date] between
#2/4/2008# and #2/8/2008#) and got the error message
"Check the subquery's syntax and enclose the subquery in
 
G

Gary Walter

oops...I forgot you have time values in [Lead Date]....

SELECT
Q.[Lead Date] AS LeadDate,
Format$(Q.[Lead Date],'mmmm yyyy') AS LeadDateByMonth,
Q.[Signed Up] AS SignedUp,
Sum(Q.[Active Recruit]) AS SumOfActiveRecruit,
Sum(Q.[Info Kit Sent]) AS SumOfInfoKitSent,
Sum(Q.[Direct Recruit]) AS SumOfDirectRecruit,
Sum(Q.[Initial Contact Made]) AS SumOfInitialContactMade,
Sum(Q.[DD Invite Letter Sent]) AS SumOfDDInviteLetterSent,
Sum(Q.[Accepted DD Invite]) AS SumOfAcceptedDDInvite,
Sum(Q.[Attended DD Mtg]) AS SumOfAttendedDDMtg,
Sum(Q.[Follow-up After DD Mtg]) AS SumOfFollowUpAfterDDMtg,
Sum(Q.[Has Contract]) AS SumOfHasContract,
Count(*) AS LeadCnt
FROM [Qry_AllDDLeads by Date Range] AS Q
GROUP BY
Q.[Lead Date],
Format$(Q.[Lead Date],'mmmm yyyy'),
Q.[Signed Up]
WHERE
CDate(NZ(Q.[Lead Date],"1900-01-01")) >= #1/28/2008#
And
CDate(NZ(Q.[Lead Date],"9999-09-09"))< #2/2/2008#;


note: last date criteria is midnight of "next day"
which will pick up those [Lead Date]'s of 2/1/2008
with a time value

(I hope that's all I goofed on)

good luck,

gary
 
S

Susan May

Gary - got this message:

Syntax error (missing operator) in query expression

Q.[Signed Up] WHERE CDate(NZ(Q.[Lead Date],"1900-01-01")) >= #1/28/2008#
And CDate(NZ(Q.[Lead Date],"9999-09-09"))< #2/2/2008#;

Can you send me back the code with the missing operator? I can't figure out
what's missing here.

Thanks a bunch!
 
G

Gary Walter

I don't see anything "wrong"...

Are you saying you copied the SQL
into SQL View of a *new query*, and
when you went into Design View it gave
you a syntax error.

Or, once you copied the SQL
into SQL View of a *new query*,
you could go into Design View,
but when you tried to save it, it gave
you a syntax error.

Did you just temporarily delete the
WHERE clause while in SQL View
to see if error went away -- so we
know error is in WHERE clause
(or in copy-pasting of SQL?).

If you copy the following to a new
query in SQL View, do you get an
error?


SELECT
Q.[Lead Date] AS LeadDate,
Format$(Q.[Lead Date],'mmmm yyyy') AS LeadDateByMonth,
Q.[Signed Up] AS SignedUp,
Sum(Q.[Active Recruit]) AS SumOfActiveRecruit,
Sum(Q.[Info Kit Sent]) AS SumOfInfoKitSent,
Sum(Q.[Direct Recruit]) AS SumOfDirectRecruit,
Sum(Q.[Initial Contact Made]) AS SumOfInitialContactMade,
Sum(Q.[DD Invite Letter Sent]) AS SumOfDDInviteLetterSent,
Sum(Q.[Accepted DD Invite]) AS SumOfAcceptedDDInvite,
Sum(Q.[Attended DD Mtg]) AS SumOfAttendedDDMtg,
Sum(Q.[Follow-up After DD Mtg]) AS SumOfFollowUpAfterDDMtg,
Sum(Q.[Has Contract]) AS SumOfHasContract,
Count(*) AS LeadCnt
FROM [Qry_AllDDLeads by Date Range] AS Q
GROUP BY
Q.[Lead Date],
Format$(Q.[Lead Date],'mmmm yyyy'),
Q.[Signed Up]
WHERE
Q.[Lead Date] >= #1/28/2008#
And
Q.[Lead Date] < #2/2/2008#;

"Susan May"wrote:
Gary - got this message:

Syntax error (missing operator) in query expression

Q.[Signed Up] WHERE CDate(NZ(Q.[Lead Date],"1900-01-01")) >= #1/28/2008#
And CDate(NZ(Q.[Lead Date],"9999-09-09"))< #2/2/2008#;

Can you send me back the code with the missing operator? I can't figure
out
what's missing here.

Thanks a bunch!
Gary Walter said:
oops...I forgot you have time values in [Lead Date]....

SELECT
Q.[Lead Date] AS LeadDate,
Format$(Q.[Lead Date],'mmmm yyyy') AS LeadDateByMonth,
Q.[Signed Up] AS SignedUp,
Sum(Q.[Active Recruit]) AS SumOfActiveRecruit,
Sum(Q.[Info Kit Sent]) AS SumOfInfoKitSent,
Sum(Q.[Direct Recruit]) AS SumOfDirectRecruit,
Sum(Q.[Initial Contact Made]) AS SumOfInitialContactMade,
Sum(Q.[DD Invite Letter Sent]) AS SumOfDDInviteLetterSent,
Sum(Q.[Accepted DD Invite]) AS SumOfAcceptedDDInvite,
Sum(Q.[Attended DD Mtg]) AS SumOfAttendedDDMtg,
Sum(Q.[Follow-up After DD Mtg]) AS SumOfFollowUpAfterDDMtg,
Sum(Q.[Has Contract]) AS SumOfHasContract,
Count(*) AS LeadCnt
FROM [Qry_AllDDLeads by Date Range] AS Q
GROUP BY
Q.[Lead Date],
Format$(Q.[Lead Date],'mmmm yyyy'),
Q.[Signed Up]
WHERE
CDate(NZ(Q.[Lead Date],"1900-01-01")) >= #1/28/2008#
And
CDate(NZ(Q.[Lead Date],"9999-09-09"))< #2/2/2008#;


note: last date criteria is midnight of "next day"
which will pick up those [Lead Date]'s of 2/1/2008
with a time value

(I hope that's all I goofed on)

good luck,

gary
 

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