Using Dates As Column Headings

  • Thread starter Thread starter eckert1961
  • Start date Start date
E

eckert1961

Hello,

This is for Access 2003. I have a table, tblDates, that contains the
following Fields that I want to use as the source for a report.

pkProjDayID
fkProjID
dteProjDay

What I want to do is to use dteProjDay as my column headings. Currenly I
have the following dates that I want to use.

4/2/2010
4/5/2010
4/7/2010
4/9/2010
4/12/2010
4/14/2010
4/16/2010
4/19/2010
4/21/2010
4/23/2010
4/26/2010
4/28/2010
4/30/2010

Each of these dates needs to become a column heading. Additionally, I only
want to use the day from each of these dates so that the headings are as
follows.

2 5 7 9 12 14 16 19 21 23 26 28 30

I've played with crosstab queries but I wasn't able to get the desired
results. Any assistance would be greatly appreciated.
 
Hi Duane,

I actually tried that but I wasn't successful. I was able to get the correct
headings but when I set the source on my report the Value was displayed
rather than the header. Part of the problem was that I don't know what field
I can set to a Value.

Any idea on how I can set the source on the report so that the header is
displayed?

Thanks.
 
I've played with Duane's suggestion and I'm not getting any closer to finding
a solution. Here is the sql of the crosstab query that I've put together.

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
FROM tblDates
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

This results in the following output:

TheYear TheMonth dteProjDay 2 5 7
2010 4 4/2/2010 1
2010 4 4/5/2010 1
2010 4 4/7/2010 1
2010 4 4/9/2010
2010 4 4/12/2010
2010 4 4/14/2010
2010 4 4/16/2010
2010 4 4/19/2010
2010 4 4/21/2010
2010 4 4/23/2010
2010 4 4/26/2010
2010 4 4/28/2010
2010 4 4/30/2010

From this I have no way of displaying the day; ie. 2, 5, 7 in the Textboxes
that make up my Report Column Headings. What get's input into the Header is
the count of 1.

What do I need to change in the query to get my desired results? Thanks.
 
I really would appreciate some assistance with this. Please let me know what
additional information is required in order to move this closer to a
resolution. Thank you.
--
Regards,
Chris


eckert1961 said:
I've played with Duane's suggestion and I'm not getting any closer to finding
a solution. Here is the sql of the crosstab query that I've put together.

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
FROM tblDates
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

This results in the following output:

TheYear TheMonth dteProjDay 2 5 7
2010 4 4/2/2010 1
2010 4 4/5/2010 1
2010 4 4/7/2010 1
2010 4 4/9/2010
2010 4 4/12/2010
2010 4 4/14/2010
2010 4 4/16/2010
2010 4 4/19/2010
2010 4 4/21/2010
2010 4 4/23/2010
2010 4 4/26/2010
2010 4 4/28/2010
2010 4 4/30/2010

From this I have no way of displaying the day; ie. 2, 5, 7 in the Textboxes
that make up my Report Column Headings. What get's input into the Header is
the count of 1.

What do I need to change in the query to get my desired results? Thanks.
--
Regards,
Chris


eckert1961 said:
Hi Duane,

I actually tried that but I wasn't successful. I was able to get the correct
headings but when I set the source on my report the Value was displayed
rather than the header. Part of the problem was that I don't know what field
I can set to a Value.

Any idea on how I can set the source on the report so that the header is
displayed?

Thanks.
 
Try this query
TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
Don't we want to remove tblDates.dteProjDay from the select and group by?

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth
GROUP BY Year([dteProjDay]), Month([dteProjDay])
PIVOT Day([dteProjDay]);

If not all days are displayed, you can add all days from 1 to 31 into the
Column Headings property.


--
Duane Hookom
Microsoft Access MVP


John Spencer said:
Try this query
TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
I've played with Duane's suggestion and I'm not getting any closer to finding
a solution. Here is the sql of the crosstab query that I've put together.

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
FROM tblDates
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

This results in the following output:

TheYear TheMonth dteProjDay 2 5 7
2010 4 4/2/2010 1
2010 4 4/5/2010 1
2010 4 4/7/2010 1
2010 4 4/9/2010
2010 4 4/12/2010
2010 4 4/14/2010
2010 4 4/16/2010
2010 4 4/19/2010
2010 4 4/21/2010
2010 4 4/23/2010
2010 4 4/26/2010
2010 4 4/28/2010
2010 4 4/30/2010

From this I have no way of displaying the day; ie. 2, 5, 7 in the Textboxes
that make up my Report Column Headings. What get's input into the Header is
the count of 1.

What do I need to change in the query to get my desired results? Thanks.
.
 
Thankyou for the response John and Duane. I tried copying/pasting Duane's Sql
statement but I get a "Syntax error in TRANSFORM statement" when I attempt to
display the Datasheet view. I can't see anything obvious. Any idea where the
issue might be?
--
Regards,
Chris


Duane Hookom said:
Don't we want to remove tblDates.dteProjDay from the select and group by?

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth
GROUP BY Year([dteProjDay]), Month([dteProjDay])
PIVOT Day([dteProjDay]);

If not all days are displayed, you can add all days from 1 to 31 into the
Column Headings property.


--
Duane Hookom
Microsoft Access MVP


John Spencer said:
Try this query
TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
I've played with Duane's suggestion and I'm not getting any closer to finding
a solution. Here is the sql of the crosstab query that I've put together.

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
FROM tblDates
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

This results in the following output:

TheYear TheMonth dteProjDay 2 5 7
2010 4 4/2/2010 1
2010 4 4/5/2010 1
2010 4 4/7/2010 1
2010 4 4/9/2010
2010 4 4/12/2010
2010 4 4/14/2010
2010 4 4/16/2010
2010 4 4/19/2010
2010 4 4/21/2010
2010 4 4/23/2010
2010 4 4/26/2010
2010 4 4/28/2010
2010 4 4/30/2010

From this I have no way of displaying the day; ie. 2, 5, 7 in the Textboxes
that make up my Report Column Headings. What get's input into the Header is
the count of 1.

What do I need to change in the query to get my desired results? Thanks.
.
 
I think I may have found the cause of the error. I added From ([tblDates])
after the SELECT statement.

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth
From ([tblDates])
GROUP BY Year([dteProjDay]), Month([dteProjDay])
PIVOT Day([dteProjDay]);

This gives me the following output.

TheYear TheMonth 2 5 7 9 12 14 16 19 21 23 26 28 30
2010 4 1 1 1 1 1 1 1 1 1 1 1 1 1

What I need is to be able to link the query to the report's column header
text boxes so that the following days for April are displayed.

2 5 7 9 .... 30

Is it possible to achieve this with the output that this query provides?
--
Regards,
Chris


eckert1961 said:
Thankyou for the response John and Duane. I tried copying/pasting Duane's Sql
statement but I get a "Syntax error in TRANSFORM statement" when I attempt to
display the Datasheet view. I can't see anything obvious. Any idea where the
issue might be?
--
Regards,
Chris


Duane Hookom said:
Don't we want to remove tblDates.dteProjDay from the select and group by?

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth
GROUP BY Year([dteProjDay]), Month([dteProjDay])
PIVOT Day([dteProjDay]);

If not all days are displayed, you can add all days from 1 to 31 into the
Column Headings property.


--
Duane Hookom
Microsoft Access MVP


John Spencer said:
Try this query
TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

eckert1961 wrote:
I've played with Duane's suggestion and I'm not getting any closer to finding
a solution. Here is the sql of the crosstab query that I've put together.

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
FROM tblDates
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

This results in the following output:

TheYear TheMonth dteProjDay 2 5 7
2010 4 4/2/2010 1
2010 4 4/5/2010 1
2010 4 4/7/2010 1
2010 4 4/9/2010
2010 4 4/12/2010
2010 4 4/14/2010
2010 4 4/16/2010
2010 4 4/19/2010
2010 4 4/21/2010
2010 4 4/23/2010
2010 4 4/26/2010
2010 4 4/28/2010
2010 4 4/30/2010

From this I have no way of displaying the day; ie. 2, 5, 7 in the Textboxes
that make up my Report Column Headings. What get's input into the Header is
the count of 1.

What do I need to change in the query to get my desired results? Thanks.
.
 
I would enter all of the dates in the column headings property of the
crosstab as suggested. Then the report will can have all the same columns.
--
Duane Hookom
Microsoft Access MVP


eckert1961 said:
I think I may have found the cause of the error. I added From ([tblDates])
after the SELECT statement.

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth
From ([tblDates])
GROUP BY Year([dteProjDay]), Month([dteProjDay])
PIVOT Day([dteProjDay]);

This gives me the following output.

TheYear TheMonth 2 5 7 9 12 14 16 19 21 23 26 28 30
2010 4 1 1 1 1 1 1 1 1 1 1 1 1 1

What I need is to be able to link the query to the report's column header
text boxes so that the following days for April are displayed.

2 5 7 9 .... 30

Is it possible to achieve this with the output that this query provides?
--
Regards,
Chris


eckert1961 said:
Thankyou for the response John and Duane. I tried copying/pasting Duane's Sql
statement but I get a "Syntax error in TRANSFORM statement" when I attempt to
display the Datasheet view. I can't see anything obvious. Any idea where the
issue might be?
--
Regards,
Chris


Duane Hookom said:
Don't we want to remove tblDates.dteProjDay from the select and group by?

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth
GROUP BY Year([dteProjDay]), Month([dteProjDay])
PIVOT Day([dteProjDay]);

If not all days are displayed, you can add all days from 1 to 31 into the
Column Headings property.


--
Duane Hookom
Microsoft Access MVP


:

Try this query
TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

eckert1961 wrote:
I've played with Duane's suggestion and I'm not getting any closer to finding
a solution. Here is the sql of the crosstab query that I've put together.

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
FROM tblDates
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

This results in the following output:

TheYear TheMonth dteProjDay 2 5 7
2010 4 4/2/2010 1
2010 4 4/5/2010 1
2010 4 4/7/2010 1
2010 4 4/9/2010
2010 4 4/12/2010
2010 4 4/14/2010
2010 4 4/16/2010
2010 4 4/19/2010
2010 4 4/21/2010
2010 4 4/23/2010
2010 4 4/26/2010
2010 4 4/28/2010
2010 4 4/30/2010

From this I have no way of displaying the day; ie. 2, 5, 7 in the Textboxes
that make up my Report Column Headings. What get's input into the Header is
the count of 1.

What do I need to change in the query to get my desired results? Thanks.
.
 
Of course. Thanks.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
Hi Duane,

My apologies but I don't follow the recommendation. Here is what I need the
output to look like.

TheYear TheMonth Day1 Day2 Day3 ....
2010 4 2 5 7

The dates under Day1, Day2, Day3 are pulled from the tables dteProjDay
field. What will I need to change to get this output? Thanks.
--
Regards,
Chris


Duane Hookom said:
I would enter all of the dates in the column headings property of the
crosstab as suggested. Then the report will can have all the same columns.
--
Duane Hookom
Microsoft Access MVP


eckert1961 said:
I think I may have found the cause of the error. I added From ([tblDates])
after the SELECT statement.

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth
From ([tblDates])
GROUP BY Year([dteProjDay]), Month([dteProjDay])
PIVOT Day([dteProjDay]);

This gives me the following output.

TheYear TheMonth 2 5 7 9 12 14 16 19 21 23 26 28 30
2010 4 1 1 1 1 1 1 1 1 1 1 1 1 1

What I need is to be able to link the query to the report's column header
text boxes so that the following days for April are displayed.

2 5 7 9 .... 30

Is it possible to achieve this with the output that this query provides?
--
Regards,
Chris


eckert1961 said:
Thankyou for the response John and Duane. I tried copying/pasting Duane's Sql
statement but I get a "Syntax error in TRANSFORM statement" when I attempt to
display the Datasheet view. I can't see anything obvious. Any idea where the
issue might be?
--
Regards,
Chris


:

Don't we want to remove tblDates.dteProjDay from the select and group by?

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth
GROUP BY Year([dteProjDay]), Month([dteProjDay])
PIVOT Day([dteProjDay]);

If not all days are displayed, you can add all days from 1 to 31 into the
Column Headings property.


--
Duane Hookom
Microsoft Access MVP


:

Try this query
TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

eckert1961 wrote:
I've played with Duane's suggestion and I'm not getting any closer to finding
a solution. Here is the sql of the crosstab query that I've put together.

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
FROM tblDates
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

This results in the following output:

TheYear TheMonth dteProjDay 2 5 7
2010 4 4/2/2010 1
2010 4 4/5/2010 1
2010 4 4/7/2010 1
2010 4 4/9/2010
2010 4 4/12/2010
2010 4 4/14/2010
2010 4 4/16/2010
2010 4 4/19/2010
2010 4 4/21/2010
2010 4 4/23/2010
2010 4 4/26/2010
2010 4 4/28/2010
2010 4 4/30/2010

From this I have no way of displaying the day; ie. 2, 5, 7 in the Textboxes
that make up my Report Column Headings. What get's input into the Header is
the count of 1.

What do I need to change in the query to get my desired results? Thanks.
.
 
I was finally able to figure it out. Changing the SQL statement to the
following gives me the desired results.

TRANSFORM First(tblDates.dteProjDay) AS [Date]
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth
FROM tblDates
GROUP BY Year([dteProjDay]), Month([dteProjDay])
PIVOT tblDates.EventLabel In ("Day 1","Day 2","Day 3","Day 4","Day 5","Day
6","Day 7","Day 8","Day 9","Day 10","Day 11","Day 12","Day 13","Day 14","Day
15");

In the report I entered the following into the text box column header
Control Source.

=DatePart("d",[Day 1])

I enter this in all 15 of the column header text boxes.

This works exactly as needed. Duane and John, thanks so much for taking the
time to assist me with this.
--
Regards,
Chris


eckert1961 said:
Hi Duane,

My apologies but I don't follow the recommendation. Here is what I need the
output to look like.

TheYear TheMonth Day1 Day2 Day3 ....
2010 4 2 5 7

The dates under Day1, Day2, Day3 are pulled from the tables dteProjDay
field. What will I need to change to get this output? Thanks.
--
Regards,
Chris


Duane Hookom said:
I would enter all of the dates in the column headings property of the
crosstab as suggested. Then the report will can have all the same columns.
--
Duane Hookom
Microsoft Access MVP


eckert1961 said:
I think I may have found the cause of the error. I added From ([tblDates])
after the SELECT statement.

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth
From ([tblDates])
GROUP BY Year([dteProjDay]), Month([dteProjDay])
PIVOT Day([dteProjDay]);

This gives me the following output.

TheYear TheMonth 2 5 7 9 12 14 16 19 21 23 26 28 30
2010 4 1 1 1 1 1 1 1 1 1 1 1 1 1

What I need is to be able to link the query to the report's column header
text boxes so that the following days for April are displayed.

2 5 7 9 .... 30

Is it possible to achieve this with the output that this query provides?
--
Regards,
Chris


:

Thankyou for the response John and Duane. I tried copying/pasting Duane's Sql
statement but I get a "Syntax error in TRANSFORM statement" when I attempt to
display the Datasheet view. I can't see anything obvious. Any idea where the
issue might be?
--
Regards,
Chris


:

Don't we want to remove tblDates.dteProjDay from the select and group by?

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth
GROUP BY Year([dteProjDay]), Month([dteProjDay])
PIVOT Day([dteProjDay]);

If not all days are displayed, you can add all days from 1 to 31 into the
Column Headings property.


--
Duane Hookom
Microsoft Access MVP


:

Try this query
TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

eckert1961 wrote:
I've played with Duane's suggestion and I'm not getting any closer to finding
a solution. Here is the sql of the crosstab query that I've put together.

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
FROM tblDates
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

This results in the following output:

TheYear TheMonth dteProjDay 2 5 7
2010 4 4/2/2010 1
2010 4 4/5/2010 1
2010 4 4/7/2010 1
2010 4 4/9/2010
2010 4 4/12/2010
2010 4 4/14/2010
2010 4 4/16/2010
2010 4 4/19/2010
2010 4 4/21/2010
2010 4 4/23/2010
2010 4 4/26/2010
2010 4 4/28/2010
2010 4 4/30/2010

From this I have no way of displaying the day; ie. 2, 5, 7 in the Textboxes
that make up my Report Column Headings. What get's input into the Header is
the count of 1.

What do I need to change in the query to get my desired results? Thanks.
.
 
I'm very confused since your original post stated:
================================
I have a table, tblDates, that contains the
following Fields that I want to use as the source for a report.

pkProjDayID
fkProjID
dteProjDay
================================
There was no mention of a field named "EventLabel" and no data that
contained values like "Day 1".

This gets a bit frustrating when we try to help and aren't given enough
information.
--
Duane Hookom
Microsoft Access MVP


eckert1961 said:
I was finally able to figure it out. Changing the SQL statement to the
following gives me the desired results.

TRANSFORM First(tblDates.dteProjDay) AS [Date]
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth
FROM tblDates
GROUP BY Year([dteProjDay]), Month([dteProjDay])
PIVOT tblDates.EventLabel In ("Day 1","Day 2","Day 3","Day 4","Day 5","Day
6","Day 7","Day 8","Day 9","Day 10","Day 11","Day 12","Day 13","Day 14","Day
15");

In the report I entered the following into the text box column header
Control Source.

=DatePart("d",[Day 1])

I enter this in all 15 of the column header text boxes.

This works exactly as needed. Duane and John, thanks so much for taking the
time to assist me with this.
--
Regards,
Chris


eckert1961 said:
Hi Duane,

My apologies but I don't follow the recommendation. Here is what I need the
output to look like.

TheYear TheMonth Day1 Day2 Day3 ....
2010 4 2 5 7

The dates under Day1, Day2, Day3 are pulled from the tables dteProjDay
field. What will I need to change to get this output? Thanks.
--
Regards,
Chris


Duane Hookom said:
I would enter all of the dates in the column headings property of the
crosstab as suggested. Then the report will can have all the same columns.
--
Duane Hookom
Microsoft Access MVP


:

I think I may have found the cause of the error. I added From ([tblDates])
after the SELECT statement.

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth
From ([tblDates])
GROUP BY Year([dteProjDay]), Month([dteProjDay])
PIVOT Day([dteProjDay]);

This gives me the following output.

TheYear TheMonth 2 5 7 9 12 14 16 19 21 23 26 28 30
2010 4 1 1 1 1 1 1 1 1 1 1 1 1 1

What I need is to be able to link the query to the report's column header
text boxes so that the following days for April are displayed.

2 5 7 9 .... 30

Is it possible to achieve this with the output that this query provides?
--
Regards,
Chris


:

Thankyou for the response John and Duane. I tried copying/pasting Duane's Sql
statement but I get a "Syntax error in TRANSFORM statement" when I attempt to
display the Datasheet view. I can't see anything obvious. Any idea where the
issue might be?
--
Regards,
Chris


:

Don't we want to remove tblDates.dteProjDay from the select and group by?

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth
GROUP BY Year([dteProjDay]), Month([dteProjDay])
PIVOT Day([dteProjDay]);

If not all days are displayed, you can add all days from 1 to 31 into the
Column Headings property.


--
Duane Hookom
Microsoft Access MVP


:

Try this query
TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

eckert1961 wrote:
I've played with Duane's suggestion and I'm not getting any closer to finding
a solution. Here is the sql of the crosstab query that I've put together.

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
FROM tblDates
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

This results in the following output:

TheYear TheMonth dteProjDay 2 5 7
2010 4 4/2/2010 1
2010 4 4/5/2010 1
2010 4 4/7/2010 1
2010 4 4/9/2010
2010 4 4/12/2010
2010 4 4/14/2010
2010 4 4/16/2010
2010 4 4/19/2010
2010 4 4/21/2010
2010 4 4/23/2010
2010 4 4/26/2010
2010 4 4/28/2010
2010 4 4/30/2010

From this I have no way of displaying the day; ie. 2, 5, 7 in the Textboxes
that make up my Report Column Headings. What get's input into the Header is
the count of 1.

What do I need to change in the query to get my desired results? Thanks.
.
 
Hi Duane,

My apologies and I understand your frustration but in my original Post the
query that I was working with only had the fields that you noted. I changed
the query to what I noted in my last POST as I was not getting the results
that I was looking for. Regarding the fields Day 1, Day 2, etc I entered
those in the Column Headings of the query property.

Your advice definitely helped me get to the finished product which I'm
extremely grateful for.

--
Regards,
Chris


Duane Hookom said:
I'm very confused since your original post stated:
================================
I have a table, tblDates, that contains the
following Fields that I want to use as the source for a report.

pkProjDayID
fkProjID
dteProjDay
================================
There was no mention of a field named "EventLabel" and no data that
contained values like "Day 1".

This gets a bit frustrating when we try to help and aren't given enough
information.
--
Duane Hookom
Microsoft Access MVP


eckert1961 said:
I was finally able to figure it out. Changing the SQL statement to the
following gives me the desired results.

TRANSFORM First(tblDates.dteProjDay) AS [Date]
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth
FROM tblDates
GROUP BY Year([dteProjDay]), Month([dteProjDay])
PIVOT tblDates.EventLabel In ("Day 1","Day 2","Day 3","Day 4","Day 5","Day
6","Day 7","Day 8","Day 9","Day 10","Day 11","Day 12","Day 13","Day 14","Day
15");

In the report I entered the following into the text box column header
Control Source.

=DatePart("d",[Day 1])

I enter this in all 15 of the column header text boxes.

This works exactly as needed. Duane and John, thanks so much for taking the
time to assist me with this.
--
Regards,
Chris


eckert1961 said:
Hi Duane,

My apologies but I don't follow the recommendation. Here is what I need the
output to look like.

TheYear TheMonth Day1 Day2 Day3 ....
2010 4 2 5 7

The dates under Day1, Day2, Day3 are pulled from the tables dteProjDay
field. What will I need to change to get this output? Thanks.
--
Regards,
Chris


:

I would enter all of the dates in the column headings property of the
crosstab as suggested. Then the report will can have all the same columns.
--
Duane Hookom
Microsoft Access MVP


:

I think I may have found the cause of the error. I added From ([tblDates])
after the SELECT statement.

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth
From ([tblDates])
GROUP BY Year([dteProjDay]), Month([dteProjDay])
PIVOT Day([dteProjDay]);

This gives me the following output.

TheYear TheMonth 2 5 7 9 12 14 16 19 21 23 26 28 30
2010 4 1 1 1 1 1 1 1 1 1 1 1 1 1

What I need is to be able to link the query to the report's column header
text boxes so that the following days for April are displayed.

2 5 7 9 .... 30

Is it possible to achieve this with the output that this query provides?
--
Regards,
Chris


:

Thankyou for the response John and Duane. I tried copying/pasting Duane's Sql
statement but I get a "Syntax error in TRANSFORM statement" when I attempt to
display the Datasheet view. I can't see anything obvious. Any idea where the
issue might be?
--
Regards,
Chris


:

Don't we want to remove tblDates.dteProjDay from the select and group by?

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth
GROUP BY Year([dteProjDay]), Month([dteProjDay])
PIVOT Day([dteProjDay]);

If not all days are displayed, you can add all days from 1 to 31 into the
Column Headings property.


--
Duane Hookom
Microsoft Access MVP


:

Try this query
TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

eckert1961 wrote:
I've played with Duane's suggestion and I'm not getting any closer to finding
a solution. Here is the sql of the crosstab query that I've put together.

TRANSFORM Count(tblDates.dteProjDay) AS CountOfdteProjDay
SELECT Year([dteProjDay]) AS TheYear, Month([dteProjDay]) AS TheMonth,
tblDates.dteProjDay
FROM tblDates
GROUP BY Year([dteProjDay]), Month([dteProjDay]), tblDates.dteProjDay
PIVOT Day([dteProjDay]);

This results in the following output:

TheYear TheMonth dteProjDay 2 5 7
2010 4 4/2/2010 1
2010 4 4/5/2010 1
2010 4 4/7/2010 1
2010 4 4/9/2010
2010 4 4/12/2010
2010 4 4/14/2010
2010 4 4/16/2010
2010 4 4/19/2010
2010 4 4/21/2010
2010 4 4/23/2010
2010 4 4/26/2010
2010 4 4/28/2010
2010 4 4/30/2010

From this I have no way of displaying the day; ie. 2, 5, 7 in the Textboxes
that make up my Report Column Headings. What get's input into the Header is
the count of 1.

What do I need to change in the query to get my desired results? Thanks.
.
 
Back
Top