Crosstab question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an unbound report with 3 subreports. The source for all the subreports
are crosstab queries. The data for the crosstab queries are 3 select queries.
If I put month(now), month(now)-1, and month(now)-2 in the select queries it
works. Is there anyway to pass parameters to the 2nd set of queries that are
input to the crosstab queries so I can run it for any 3 months?
 
If you have a control on a form "Forms!frmDates!txtDate", you might be able
to replace "Now" with "Forms!frmDates!txtDate".

However, you haven't shown us your SQL view of the crosstabs.
 
Duane

I have tried using a from combo box for this and I get the following error
message: "The Microsoft Jet database engine does not recognize
'Forms!SwitchBoard!SelectMonth' as a valid field name or expression". I have
used the "Build" function in the query to find the field on the form instead
of typing it in myself.

John
 
This question gets asked and answered here quite often. You must enter the
parameter data types into the Query->Parameters:
Forms!SwitchBoard!SelectMonth Integer
 
Duane

I am using the monthname of the month, a string instead of the number of the
month which would be an integer. Here is what the query says with the
parameter:

Select Query - QryMonthCurr
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE (((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

Crosstab Query
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate;

John
 
Change the parameter type to "Text".

--
Duane Hookom
MS Access MVP


jbruen said:
Duane

I am using the monthname of the month, a string instead of the number of
the
month which would be an integer. Here is what the query says with the
parameter:

Select Query - QryMonthCurr
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

Crosstab Query
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate;

John

Duane Hookom said:
This question gets asked and answered here quite often. You must enter
the
parameter data types into the Query->Parameters:
Forms!SwitchBoard!SelectMonth Integer
 
Duane

If I run the crosstab query from the database window, it prompts once as
[Forms]![Switchboard]![SelectMonth] and works fine.

PARAMETERS [Forms]![Switchboard]![SelectMonth] Text ( 255 );
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE (((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

When I run the report it prompts twice showing
[Forms]![Switchboard]![SelectMonth] in the title then the following error
comes up: "You can't use a pass-through query or an non-fixed-column crosstab
query as a record source for a subform or subreport. Before you bind the
subform or subreport to a crosstab query, set the query's ColumnHeadings
peoperty."

After reading help, I have to put the exact field names in the
ColumnHeadings field. How can I run it for a selected month. The output
titles for July example would be "Type", "7/3/2005", "7/10/2005",
"7/17/2005", "7/24/2005", "7/31/2005" but for August would be "Type",
"8/7/2005", "8/14/2005", "8/21/2005", "8/28/2005".

John

Duane Hookom said:
Change the parameter type to "Text".

--
Duane Hookom
MS Access MVP


jbruen said:
Duane

I am using the monthname of the month, a string instead of the number of
the
month which would be an integer. Here is what the query says with the
parameter:

Select Query - QryMonthCurr
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

Crosstab Query
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate;

John

Duane Hookom said:
This question gets asked and answered here quite often. You must enter
the
parameter data types into the Query->Parameters:
Forms!SwitchBoard!SelectMonth Integer
--
Duane Hookom
MS Access MVP


Duane

I have tried using a from combo box for this and I get the following
error
message: "The Microsoft Jet database engine does not recognize
'Forms!SwitchBoard!SelectMonth' as a valid field name or expression". I
have
used the "Build" function in the query to find the field on the form
instead
of typing it in myself.

John

:

If you have a control on a form "Forms!frmDates!txtDate", you might be
able
to replace "Now" with "Forms!frmDates!txtDate".

However, you haven't shown us your SQL view of the crosstabs.

--
Duane Hookom
MS Access MVP
--

I have an unbound report with 3 subreports. The source for all the
subreports
are crosstab queries. The data for the crosstab queries are 3 select
queries.
If I put month(now), month(now)-1, and month(now)-2 in the select
queries
it
works. Is there anyway to pass parameters to the 2nd set of queries
that
are
input to the crosstab queries so I can run it for any 3 months?
 
The switchboard form must be open when running the query/report.

I would use relative dates for column headings. For instance if you had a
date value in a text box "txtEndDate" on your form, you could set the column
headings expession to:
ColHead:"W" & DateDiff("ww",[CalDate], [Forms]![Switchboard]![TxtEndDate])

Set the Query->Parameter
[Forms]![Switchboard]![TxtEndDate] DateTime

Set the column Headings property to:
"W0","W1","W2","W3","W4"

--
Duane Hookom
MS Access MVP


jbruen said:
Duane

If I run the crosstab query from the database window, it prompts once as
[Forms]![Switchboard]![SelectMonth] and works fine.

PARAMETERS [Forms]![Switchboard]![SelectMonth] Text ( 255 );
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

When I run the report it prompts twice showing
[Forms]![Switchboard]![SelectMonth] in the title then the following error
comes up: "You can't use a pass-through query or an non-fixed-column
crosstab
query as a record source for a subform or subreport. Before you bind the
subform or subreport to a crosstab query, set the query's ColumnHeadings
peoperty."

After reading help, I have to put the exact field names in the
ColumnHeadings field. How can I run it for a selected month. The output
titles for July example would be "Type", "7/3/2005", "7/10/2005",
"7/17/2005", "7/24/2005", "7/31/2005" but for August would be "Type",
"8/7/2005", "8/14/2005", "8/21/2005", "8/28/2005".

John

Duane Hookom said:
Change the parameter type to "Text".

--
Duane Hookom
MS Access MVP


jbruen said:
Duane

I am using the monthname of the month, a string instead of the number
of
the
month which would be an integer. Here is what the query says with the
parameter:

Select Query - QryMonthCurr
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

Crosstab Query
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate;

John

:

This question gets asked and answered here quite often. You must enter
the
parameter data types into the Query->Parameters:
Forms!SwitchBoard!SelectMonth Integer
--
Duane Hookom
MS Access MVP


Duane

I have tried using a from combo box for this and I get the following
error
message: "The Microsoft Jet database engine does not recognize
'Forms!SwitchBoard!SelectMonth' as a valid field name or
expression". I
have
used the "Build" function in the query to find the field on the form
instead
of typing it in myself.

John

:

If you have a control on a form "Forms!frmDates!txtDate", you might
be
able
to replace "Now" with "Forms!frmDates!txtDate".

However, you haven't shown us your SQL view of the crosstabs.

--
Duane Hookom
MS Access MVP
--

I have an unbound report with 3 subreports. The source for all the
subreports
are crosstab queries. The data for the crosstab queries are 3
select
queries.
If I put month(now), month(now)-1, and month(now)-2 in the select
queries
it
works. Is there anyway to pass parameters to the 2nd set of
queries
that
are
input to the crosstab queries so I can run it for any 3 months?
 
Duane

Where do I set the ColHead: field below up? I think I set the "W0",W1" etc
up in the ColumnHeadings in the crosstab query properties.

Can I use the query for the source of the subreport or should I set up a
separate report with the crosstab query as the sorce?

If I try and run a report with the crosstab as the source, I received the
followng message after enter 1/1/05 for the prompt: "This expression is typed
incorrectly, or it is too complex to be evaluated. For example, a numeric
expression may contain too many complicated elements. Try simplifying the
expression by assigning parts of the expression to variables. "

Is there anyway to send this database to you?

John

Duane Hookom said:
The switchboard form must be open when running the query/report.

I would use relative dates for column headings. For instance if you had a
date value in a text box "txtEndDate" on your form, you could set the column
headings expession to:
ColHead:"W" & DateDiff("ww",[CalDate], [Forms]![Switchboard]![TxtEndDate])

Set the Query->Parameter
[Forms]![Switchboard]![TxtEndDate] DateTime

Set the column Headings property to:
"W0","W1","W2","W3","W4"

--
Duane Hookom
MS Access MVP


jbruen said:
Duane

If I run the crosstab query from the database window, it prompts once as
[Forms]![Switchboard]![SelectMonth] and works fine.

PARAMETERS [Forms]![Switchboard]![SelectMonth] Text ( 255 );
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

When I run the report it prompts twice showing
[Forms]![Switchboard]![SelectMonth] in the title then the following error
comes up: "You can't use a pass-through query or an non-fixed-column
crosstab
query as a record source for a subform or subreport. Before you bind the
subform or subreport to a crosstab query, set the query's ColumnHeadings
peoperty."

After reading help, I have to put the exact field names in the
ColumnHeadings field. How can I run it for a selected month. The output
titles for July example would be "Type", "7/3/2005", "7/10/2005",
"7/17/2005", "7/24/2005", "7/31/2005" but for August would be "Type",
"8/7/2005", "8/14/2005", "8/21/2005", "8/28/2005".

John

Duane Hookom said:
Change the parameter type to "Text".

--
Duane Hookom
MS Access MVP


Duane

I am using the monthname of the month, a string instead of the number
of
the
month which would be an integer. Here is what the query says with the
parameter:

Select Query - QryMonthCurr
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

Crosstab Query
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate;

John

:

This question gets asked and answered here quite often. You must enter
the
parameter data types into the Query->Parameters:
Forms!SwitchBoard!SelectMonth Integer
--
Duane Hookom
MS Access MVP


Duane

I have tried using a from combo box for this and I get the following
error
message: "The Microsoft Jet database engine does not recognize
'Forms!SwitchBoard!SelectMonth' as a valid field name or
expression". I
have
used the "Build" function in the query to find the field on the form
instead
of typing it in myself.

John

:

If you have a control on a form "Forms!frmDates!txtDate", you might
be
able
to replace "Now" with "Forms!frmDates!txtDate".

However, you haven't shown us your SQL view of the crosstabs.

--
Duane Hookom
MS Access MVP
--

I have an unbound report with 3 subreports. The source for all the
subreports
are crosstab queries. The data for the crosstab queries are 3
select
queries.
If I put month(now), month(now)-1, and month(now)-2 in the select
queries
it
works. Is there anyway to pass parameters to the 2nd set of
queries
that
are
input to the crosstab queries so I can run it for any 3 months?
 
You use the "ColHead:"W" & DateDiff("ww",[CalDate..." as the column in your
query grid that generates the column headings.

If you follow my instructions, you can use the crosstab as the record source
of a subreport.

Just post the SQL view of your best attempt at the solution.

--
Duane Hookom
MS Access MVP


jbruen said:
Duane

Where do I set the ColHead: field below up? I think I set the "W0",W1" etc
up in the ColumnHeadings in the crosstab query properties.

Can I use the query for the source of the subreport or should I set up a
separate report with the crosstab query as the sorce?

If I try and run a report with the crosstab as the source, I received the
followng message after enter 1/1/05 for the prompt: "This expression is
typed
incorrectly, or it is too complex to be evaluated. For example, a numeric
expression may contain too many complicated elements. Try simplifying the
expression by assigning parts of the expression to variables. "

Is there anyway to send this database to you?

John

Duane Hookom said:
The switchboard form must be open when running the query/report.

I would use relative dates for column headings. For instance if you had a
date value in a text box "txtEndDate" on your form, you could set the
column
headings expession to:
ColHead:"W" & DateDiff("ww",[CalDate],
[Forms]![Switchboard]![TxtEndDate])

Set the Query->Parameter
[Forms]![Switchboard]![TxtEndDate] DateTime

Set the column Headings property to:
"W0","W1","W2","W3","W4"

--
Duane Hookom
MS Access MVP


jbruen said:
Duane

If I run the crosstab query from the database window, it prompts once
as
[Forms]![Switchboard]![SelectMonth] and works fine.

PARAMETERS [Forms]![Switchboard]![SelectMonth] Text ( 255 );
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

When I run the report it prompts twice showing
[Forms]![Switchboard]![SelectMonth] in the title then the following
error
comes up: "You can't use a pass-through query or an non-fixed-column
crosstab
query as a record source for a subform or subreport. Before you bind
the
subform or subreport to a crosstab query, set the query's
ColumnHeadings
peoperty."

After reading help, I have to put the exact field names in the
ColumnHeadings field. How can I run it for a selected month. The output
titles for July example would be "Type", "7/3/2005", "7/10/2005",
"7/17/2005", "7/24/2005", "7/31/2005" but for August would be "Type",
"8/7/2005", "8/14/2005", "8/21/2005", "8/28/2005".

John

:

Change the parameter type to "Text".

--
Duane Hookom
MS Access MVP


Duane

I am using the monthname of the month, a string instead of the
number
of
the
month which would be an integer. Here is what the query says with
the
parameter:

Select Query - QryMonthCurr
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

Crosstab Query
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate;

John

:

This question gets asked and answered here quite often. You must
enter
the
parameter data types into the Query->Parameters:
Forms!SwitchBoard!SelectMonth Integer
--
Duane Hookom
MS Access MVP


Duane

I have tried using a from combo box for this and I get the
following
error
message: "The Microsoft Jet database engine does not recognize
'Forms!SwitchBoard!SelectMonth' as a valid field name or
expression". I
have
used the "Build" function in the query to find the field on the
form
instead
of typing it in myself.

John

:

If you have a control on a form "Forms!frmDates!txtDate", you
might
be
able
to replace "Now" with "Forms!frmDates!txtDate".

However, you haven't shown us your SQL view of the crosstabs.

--
Duane Hookom
MS Access MVP
--

I have an unbound report with 3 subreports. The source for all
the
subreports
are crosstab queries. The data for the crosstab queries are 3
select
queries.
If I put month(now), month(now)-1, and month(now)-2 in the
select
queries
it
works. Is there anyway to pass parameters to the 2nd set of
queries
that
are
input to the crosstab queries so I can run it for any 3
months?
 
Duane

Below are the two queries. After I select the dates in the 3 combo boxes I
receive the following error message: "There is an error executing the
command" when running from the switchboard. If I try and open the report from
the database window, I get prompted for 1 date and receive the following
error message: "This expression is typed incorrectly, or it is too complex to
be evaluated. For example, a numeric expression may contain too many
complicated elements. Try simplifying the expression by assigning parts of
the expression to variables. "

How should the queries look when I get finished?

Where do I set the column headings expession to: ColHead:"W" &
DateDiff("ww",CalDate], [Forms]![Switchboard]![FirstDate]) ?

---1st Select Query - QryMonthCurr
PARAMETERS [Forms]![Switchboard]![FirstDate] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE (((MonthName(Month([caldate])))=[Forms]![Switchboard]![FirstDate]));

---2nd Select Query - QryMonthPrev1
PARAMETERS [Forms]![Switchboard]![SelectMonth] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE (((MonthName(Month([caldate])))=[Forms]![Switchboard]![SecondDate]));

---3rd Select Query - QryMonthPrev2
PARAMETERS [Forms]![Switchboard]![SelectMonth] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE (((MonthName(Month([caldate])))=[Forms]![Switchboard]![ThirdDate]));

--1st CrossTab Query - QryNewCrosstabCurr
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate In ("W0","W1","W2","w3","w4","w5");

--2nd CrossTab Query - QryNewCrosstabPrev1
TRANSFORM Sum(QryMonthPrev1.Amount) AS SumOfAmount
SELECT QryMonthPrev1.Type
FROM QryMonthPrev1
GROUP BY QryMonthPrev1.Type
ORDER BY QryMonthPrev1.Type, QryMonthPrev1.CalDate
PIVOT QryMonthPrev1.CalDate In ("W0","W1","W2","w3","w4","w5");

--3rd CrossTab Query - QryNewCrosstabPrev2
TRANSFORM Sum(QryMonthPrev2.Amount) AS SumOfAmount
SELECT QryMonthPrev2.Type
FROM QryMonthPrev2
GROUP BY QryMonthPrev2.Type
ORDER BY QryMonthPrev2.Type, QryMonthPrev2.CalDate
PIVOT QryMonthPrev2.CalDate In ("W0","W1","W2","w3","w4","w5");

I tried this query since I could not figure out how I was going to get the
whole month with the date selection you were showing me:

PARAMETERS [Forms]![Switchboard]![FirstDate] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
Month([caldate]) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE (((Month([caldate]))=Month([Forms]![Switchboard]![FirstDate])));

When I run the crosstab I still get the message:"This expression is typed
incorrectly, or it is too complex to be evaluated. For example, a numeric
expression may contain too many complicated elements. Try simplifying the
expression by assigning parts of the expression to variables."

John


Duane Hookom said:
You use the "ColHead:"W" & DateDiff("ww",[CalDate..." as the column in your
query grid that generates the column headings.

If you follow my instructions, you can use the crosstab as the record source
of a subreport.

Just post the SQL view of your best attempt at the solution.

--
Duane Hookom
MS Access MVP


jbruen said:
Duane

Where do I set the ColHead: field below up? I think I set the "W0",W1" etc
up in the ColumnHeadings in the crosstab query properties.

Can I use the query for the source of the subreport or should I set up a
separate report with the crosstab query as the sorce?

If I try and run a report with the crosstab as the source, I received the
followng message after enter 1/1/05 for the prompt: "This expression is
typed
incorrectly, or it is too complex to be evaluated. For example, a numeric
expression may contain too many complicated elements. Try simplifying the
expression by assigning parts of the expression to variables. "

Is there anyway to send this database to you?

John

Duane Hookom said:
The switchboard form must be open when running the query/report.

I would use relative dates for column headings. For instance if you had a
date value in a text box "txtEndDate" on your form, you could set the
column
headings expession to:
ColHead:"W" & DateDiff("ww",[CalDate],
[Forms]![Switchboard]![TxtEndDate])

Set the Query->Parameter
[Forms]![Switchboard]![TxtEndDate] DateTime

Set the column Headings property to:
"W0","W1","W2","W3","W4"

--
Duane Hookom
MS Access MVP


Duane

If I run the crosstab query from the database window, it prompts once
as
[Forms]![Switchboard]![SelectMonth] and works fine.

PARAMETERS [Forms]![Switchboard]![SelectMonth] Text ( 255 );
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

When I run the report it prompts twice showing
[Forms]![Switchboard]![SelectMonth] in the title then the following
error
comes up: "You can't use a pass-through query or an non-fixed-column
crosstab
query as a record source for a subform or subreport. Before you bind
the
subform or subreport to a crosstab query, set the query's
ColumnHeadings
peoperty."

After reading help, I have to put the exact field names in the
ColumnHeadings field. How can I run it for a selected month. The output
titles for July example would be "Type", "7/3/2005", "7/10/2005",
"7/17/2005", "7/24/2005", "7/31/2005" but for August would be "Type",
"8/7/2005", "8/14/2005", "8/21/2005", "8/28/2005".

John

:

Change the parameter type to "Text".

--
Duane Hookom
MS Access MVP


Duane

I am using the monthname of the month, a string instead of the
number
of
the
month which would be an integer. Here is what the query says with
the
parameter:

Select Query - QryMonthCurr
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

Crosstab Query
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate;

John

:

This question gets asked and answered here quite often. You must
enter
the
parameter data types into the Query->Parameters:
Forms!SwitchBoard!SelectMonth Integer
--
Duane Hookom
MS Access MVP


Duane

I have tried using a from combo box for this and I get the
following
error
message: "The Microsoft Jet database engine does not recognize
'Forms!SwitchBoard!SelectMonth' as a valid field name or
expression". I
have
used the "Build" function in the query to find the field on the
form
instead
of typing it in myself.

John

:

If you have a control on a form "Forms!frmDates!txtDate", you
might
be
able
to replace "Now" with "Forms!frmDates!txtDate".

However, you haven't shown us your SQL view of the crosstabs.

--
Duane Hookom
MS Access MVP
--

I have an unbound report with 3 subreports. The source for all
the
subreports
are crosstab queries. The data for the crosstab queries are 3
select
queries.
If I put month(now), month(now)-1, and month(now)-2 in the
select
queries
it
works. Is there anyway to pass parameters to the 2nd set of
queries
that
are
input to the crosstab queries so I can run it for any 3
months?
 
I wish I knew what you had for tables and records as well as your desired
format/display of that data in your report.

--
Duane Hookom
MS Access MVP


jbruen said:
Duane

Below are the two queries. After I select the dates in the 3 combo boxes I
receive the following error message: "There is an error executing the
command" when running from the switchboard. If I try and open the report
from
the database window, I get prompted for 1 date and receive the following
error message: "This expression is typed incorrectly, or it is too complex
to
be evaluated. For example, a numeric expression may contain too many
complicated elements. Try simplifying the expression by assigning parts of
the expression to variables. "

How should the queries look when I get finished?

Where do I set the column headings expession to: ColHead:"W" &
DateDiff("ww",CalDate], [Forms]![Switchboard]![FirstDate]) ?

---1st Select Query - QryMonthCurr
PARAMETERS [Forms]![Switchboard]![FirstDate] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE (((MonthName(Month([caldate])))=[Forms]![Switchboard]![FirstDate]));

---2nd Select Query - QryMonthPrev1
PARAMETERS [Forms]![Switchboard]![SelectMonth] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SecondDate]));

---3rd Select Query - QryMonthPrev2
PARAMETERS [Forms]![Switchboard]![SelectMonth] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE (((MonthName(Month([caldate])))=[Forms]![Switchboard]![ThirdDate]));

--1st CrossTab Query - QryNewCrosstabCurr
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate In ("W0","W1","W2","w3","w4","w5");

--2nd CrossTab Query - QryNewCrosstabPrev1
TRANSFORM Sum(QryMonthPrev1.Amount) AS SumOfAmount
SELECT QryMonthPrev1.Type
FROM QryMonthPrev1
GROUP BY QryMonthPrev1.Type
ORDER BY QryMonthPrev1.Type, QryMonthPrev1.CalDate
PIVOT QryMonthPrev1.CalDate In ("W0","W1","W2","w3","w4","w5");

--3rd CrossTab Query - QryNewCrosstabPrev2
TRANSFORM Sum(QryMonthPrev2.Amount) AS SumOfAmount
SELECT QryMonthPrev2.Type
FROM QryMonthPrev2
GROUP BY QryMonthPrev2.Type
ORDER BY QryMonthPrev2.Type, QryMonthPrev2.CalDate
PIVOT QryMonthPrev2.CalDate In ("W0","W1","W2","w3","w4","w5");

I tried this query since I could not figure out how I was going to get the
whole month with the date selection you were showing me:

PARAMETERS [Forms]![Switchboard]![FirstDate] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
Month([caldate]) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE (((Month([caldate]))=Month([Forms]![Switchboard]![FirstDate])));

When I run the crosstab I still get the message:"This expression is typed
incorrectly, or it is too complex to be evaluated. For example, a numeric
expression may contain too many complicated elements. Try simplifying the
expression by assigning parts of the expression to variables."

John


Duane Hookom said:
You use the "ColHead:"W" & DateDiff("ww",[CalDate..." as the column in
your
query grid that generates the column headings.

If you follow my instructions, you can use the crosstab as the record
source
of a subreport.

Just post the SQL view of your best attempt at the solution.

--
Duane Hookom
MS Access MVP


jbruen said:
Duane

Where do I set the ColHead: field below up? I think I set the "W0",W1"
etc
up in the ColumnHeadings in the crosstab query properties.

Can I use the query for the source of the subreport or should I set up
a
separate report with the crosstab query as the sorce?

If I try and run a report with the crosstab as the source, I received
the
followng message after enter 1/1/05 for the prompt: "This expression is
typed
incorrectly, or it is too complex to be evaluated. For example, a
numeric
expression may contain too many complicated elements. Try simplifying
the
expression by assigning parts of the expression to variables. "

Is there anyway to send this database to you?

John

:

The switchboard form must be open when running the query/report.

I would use relative dates for column headings. For instance if you
had a
date value in a text box "txtEndDate" on your form, you could set the
column
headings expession to:
ColHead:"W" & DateDiff("ww",[CalDate],
[Forms]![Switchboard]![TxtEndDate])

Set the Query->Parameter
[Forms]![Switchboard]![TxtEndDate] DateTime

Set the column Headings property to:
"W0","W1","W2","W3","W4"

--
Duane Hookom
MS Access MVP


Duane

If I run the crosstab query from the database window, it prompts
once
as
[Forms]![Switchboard]![SelectMonth] and works fine.

PARAMETERS [Forms]![Switchboard]![SelectMonth] Text ( 255 );
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

When I run the report it prompts twice showing
[Forms]![Switchboard]![SelectMonth] in the title then the following
error
comes up: "You can't use a pass-through query or an non-fixed-column
crosstab
query as a record source for a subform or subreport. Before you bind
the
subform or subreport to a crosstab query, set the query's
ColumnHeadings
peoperty."

After reading help, I have to put the exact field names in the
ColumnHeadings field. How can I run it for a selected month. The
output
titles for July example would be "Type", "7/3/2005", "7/10/2005",
"7/17/2005", "7/24/2005", "7/31/2005" but for August would be
"Type",
"8/7/2005", "8/14/2005", "8/21/2005", "8/28/2005".

John

:

Change the parameter type to "Text".

--
Duane Hookom
MS Access MVP


Duane

I am using the monthname of the month, a string instead of the
number
of
the
month which would be an integer. Here is what the query says with
the
parameter:

Select Query - QryMonthCurr
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON
TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

Crosstab Query
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate;

John

:

This question gets asked and answered here quite often. You must
enter
the
parameter data types into the Query->Parameters:
Forms!SwitchBoard!SelectMonth Integer
--
Duane Hookom
MS Access MVP


Duane

I have tried using a from combo box for this and I get the
following
error
message: "The Microsoft Jet database engine does not recognize
'Forms!SwitchBoard!SelectMonth' as a valid field name or
expression". I
have
used the "Build" function in the query to find the field on
the
form
instead
of typing it in myself.

John

:

If you have a control on a form "Forms!frmDates!txtDate", you
might
be
able
to replace "Now" with "Forms!frmDates!txtDate".

However, you haven't shown us your SQL view of the crosstabs.

--
Duane Hookom
MS Access MVP
--

I have an unbound report with 3 subreports. The source for
all
the
subreports
are crosstab queries. The data for the crosstab queries are
3
select
queries.
If I put month(now), month(now)-1, and month(now)-2 in the
select
queries
it
works. Is there anyway to pass parameters to the 2nd set of
queries
that
are
input to the crosstab queries so I can run it for any 3
months?
 
Duane

Below is the table. I'm trying to get a crosstab query so the Date/week is
the column, Type is the row and it's summed by the amount. Then I create this
3 seperate times, showing types by Current Month by date/week on the first
line, showing types by Current Month -1 by date/week on the second line and
showing types by Current Month -3 by date/week on the third line. This is how
the 3 months would make up the sub reports.

CalDate Date/Time 8
Envelope Long Integer 4
Type Text 50
Amount Currency 8
CheckNumber Long Integer 4
Memo Memo -

John

Duane Hookom said:
I wish I knew what you had for tables and records as well as your desired
format/display of that data in your report.

--
Duane Hookom
MS Access MVP


jbruen said:
Duane

Below are the two queries. After I select the dates in the 3 combo boxes I
receive the following error message: "There is an error executing the
command" when running from the switchboard. If I try and open the report
from
the database window, I get prompted for 1 date and receive the following
error message: "This expression is typed incorrectly, or it is too complex
to
be evaluated. For example, a numeric expression may contain too many
complicated elements. Try simplifying the expression by assigning parts of
the expression to variables. "

How should the queries look when I get finished?

Where do I set the column headings expession to: ColHead:"W" &
DateDiff("ww",CalDate], [Forms]![Switchboard]![FirstDate]) ?

---1st Select Query - QryMonthCurr
PARAMETERS [Forms]![Switchboard]![FirstDate] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE (((MonthName(Month([caldate])))=[Forms]![Switchboard]![FirstDate]));

---2nd Select Query - QryMonthPrev1
PARAMETERS [Forms]![Switchboard]![SelectMonth] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SecondDate]));

---3rd Select Query - QryMonthPrev2
PARAMETERS [Forms]![Switchboard]![SelectMonth] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE (((MonthName(Month([caldate])))=[Forms]![Switchboard]![ThirdDate]));

--1st CrossTab Query - QryNewCrosstabCurr
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate In ("W0","W1","W2","w3","w4","w5");

--2nd CrossTab Query - QryNewCrosstabPrev1
TRANSFORM Sum(QryMonthPrev1.Amount) AS SumOfAmount
SELECT QryMonthPrev1.Type
FROM QryMonthPrev1
GROUP BY QryMonthPrev1.Type
ORDER BY QryMonthPrev1.Type, QryMonthPrev1.CalDate
PIVOT QryMonthPrev1.CalDate In ("W0","W1","W2","w3","w4","w5");

--3rd CrossTab Query - QryNewCrosstabPrev2
TRANSFORM Sum(QryMonthPrev2.Amount) AS SumOfAmount
SELECT QryMonthPrev2.Type
FROM QryMonthPrev2
GROUP BY QryMonthPrev2.Type
ORDER BY QryMonthPrev2.Type, QryMonthPrev2.CalDate
PIVOT QryMonthPrev2.CalDate In ("W0","W1","W2","w3","w4","w5");

I tried this query since I could not figure out how I was going to get the
whole month with the date selection you were showing me:

PARAMETERS [Forms]![Switchboard]![FirstDate] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
Month([caldate]) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE (((Month([caldate]))=Month([Forms]![Switchboard]![FirstDate])));

When I run the crosstab I still get the message:"This expression is typed
incorrectly, or it is too complex to be evaluated. For example, a numeric
expression may contain too many complicated elements. Try simplifying the
expression by assigning parts of the expression to variables."

John


Duane Hookom said:
You use the "ColHead:"W" & DateDiff("ww",[CalDate..." as the column in
your
query grid that generates the column headings.

If you follow my instructions, you can use the crosstab as the record
source
of a subreport.

Just post the SQL view of your best attempt at the solution.

--
Duane Hookom
MS Access MVP


Duane

Where do I set the ColHead: field below up? I think I set the "W0",W1"
etc
up in the ColumnHeadings in the crosstab query properties.

Can I use the query for the source of the subreport or should I set up
a
separate report with the crosstab query as the sorce?

If I try and run a report with the crosstab as the source, I received
the
followng message after enter 1/1/05 for the prompt: "This expression is
typed
incorrectly, or it is too complex to be evaluated. For example, a
numeric
expression may contain too many complicated elements. Try simplifying
the
expression by assigning parts of the expression to variables. "

Is there anyway to send this database to you?

John

:

The switchboard form must be open when running the query/report.

I would use relative dates for column headings. For instance if you
had a
date value in a text box "txtEndDate" on your form, you could set the
column
headings expession to:
ColHead:"W" & DateDiff("ww",[CalDate],
[Forms]![Switchboard]![TxtEndDate])

Set the Query->Parameter
[Forms]![Switchboard]![TxtEndDate] DateTime

Set the column Headings property to:
"W0","W1","W2","W3","W4"

--
Duane Hookom
MS Access MVP


Duane

If I run the crosstab query from the database window, it prompts
once
as
[Forms]![Switchboard]![SelectMonth] and works fine.

PARAMETERS [Forms]![Switchboard]![SelectMonth] Text ( 255 );
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

When I run the report it prompts twice showing
[Forms]![Switchboard]![SelectMonth] in the title then the following
error
comes up: "You can't use a pass-through query or an non-fixed-column
crosstab
query as a record source for a subform or subreport. Before you bind
the
subform or subreport to a crosstab query, set the query's
ColumnHeadings
peoperty."

After reading help, I have to put the exact field names in the
ColumnHeadings field. How can I run it for a selected month. The
output
titles for July example would be "Type", "7/3/2005", "7/10/2005",
"7/17/2005", "7/24/2005", "7/31/2005" but for August would be
"Type",
"8/7/2005", "8/14/2005", "8/21/2005", "8/28/2005".

John

:

Change the parameter type to "Text".

--
Duane Hookom
MS Access MVP


Duane

I am using the monthname of the month, a string instead of the
number
of
the
month which would be an integer. Here is what the query says with
the
parameter:

Select Query - QryMonthCurr
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON
TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

Crosstab Query
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate;

John

:

This question gets asked and answered here quite often. You must
enter
the
parameter data types into the Query->Parameters:
Forms!SwitchBoard!SelectMonth Integer
--
Duane Hookom
MS Access MVP


Duane

I have tried using a from combo box for this and I get the
following
error
message: "The Microsoft Jet database engine does not recognize
'Forms!SwitchBoard!SelectMonth' as a valid field name or
expression". I
have
used the "Build" function in the query to find the field on
the
form
instead
of typing it in myself.

John

:

If you have a control on a form "Forms!frmDates!txtDate", you
might
be
able
to replace "Now" with "Forms!frmDates!txtDate".

However, you haven't shown us your SQL view of the crosstabs.

--
Duane Hookom
MS Access MVP
--

I have an unbound report with 3 subreports. The source for
all
the
subreports
are crosstab queries. The data for the crosstab queries are
3
select
queries.
If I put month(now), month(now)-1, and month(now)-2 in the
 
Why are you creating three separate crosstabs (one for each of three months)
when it seems that you should be able to add a month row heading to a single
crosstab?

--
Duane Hookom
MS Access MVP


jbruen said:
Duane

Below is the table. I'm trying to get a crosstab query so the Date/week is
the column, Type is the row and it's summed by the amount. Then I create
this
3 seperate times, showing types by Current Month by date/week on the first
line, showing types by Current Month -1 by date/week on the second line
and
showing types by Current Month -3 by date/week on the third line. This is
how
the 3 months would make up the sub reports.

CalDate Date/Time 8
Envelope Long Integer 4
Type Text 50
Amount Currency 8
CheckNumber Long Integer 4
Memo Memo -

John

Duane Hookom said:
I wish I knew what you had for tables and records as well as your desired
format/display of that data in your report.

--
Duane Hookom
MS Access MVP


jbruen said:
Duane

Below are the two queries. After I select the dates in the 3 combo
boxes I
receive the following error message: "There is an error executing the
command" when running from the switchboard. If I try and open the
report
from
the database window, I get prompted for 1 date and receive the
following
error message: "This expression is typed incorrectly, or it is too
complex
to
be evaluated. For example, a numeric expression may contain too many
complicated elements. Try simplifying the expression by assigning parts
of
the expression to variables. "

How should the queries look when I get finished?

Where do I set the column headings expession to: ColHead:"W" &
DateDiff("ww",CalDate], [Forms]![Switchboard]![FirstDate]) ?

---1st Select Query - QryMonthCurr
PARAMETERS [Forms]![Switchboard]![FirstDate] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![FirstDate]));

---2nd Select Query - QryMonthPrev1
PARAMETERS [Forms]![Switchboard]![SelectMonth] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SecondDate]));

---3rd Select Query - QryMonthPrev2
PARAMETERS [Forms]![Switchboard]![SelectMonth] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![ThirdDate]));

--1st CrossTab Query - QryNewCrosstabCurr
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate In ("W0","W1","W2","w3","w4","w5");

--2nd CrossTab Query - QryNewCrosstabPrev1
TRANSFORM Sum(QryMonthPrev1.Amount) AS SumOfAmount
SELECT QryMonthPrev1.Type
FROM QryMonthPrev1
GROUP BY QryMonthPrev1.Type
ORDER BY QryMonthPrev1.Type, QryMonthPrev1.CalDate
PIVOT QryMonthPrev1.CalDate In ("W0","W1","W2","w3","w4","w5");

--3rd CrossTab Query - QryNewCrosstabPrev2
TRANSFORM Sum(QryMonthPrev2.Amount) AS SumOfAmount
SELECT QryMonthPrev2.Type
FROM QryMonthPrev2
GROUP BY QryMonthPrev2.Type
ORDER BY QryMonthPrev2.Type, QryMonthPrev2.CalDate
PIVOT QryMonthPrev2.CalDate In ("W0","W1","W2","w3","w4","w5");

I tried this query since I could not figure out how I was going to get
the
whole month with the date selection you were showing me:

PARAMETERS [Forms]![Switchboard]![FirstDate] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
Month([caldate]) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE (((Month([caldate]))=Month([Forms]![Switchboard]![FirstDate])));

When I run the crosstab I still get the message:"This expression is
typed
incorrectly, or it is too complex to be evaluated. For example, a
numeric
expression may contain too many complicated elements. Try simplifying
the
expression by assigning parts of the expression to variables."

John


:

You use the "ColHead:"W" & DateDiff("ww",[CalDate..." as the column in
your
query grid that generates the column headings.

If you follow my instructions, you can use the crosstab as the record
source
of a subreport.

Just post the SQL view of your best attempt at the solution.

--
Duane Hookom
MS Access MVP


Duane

Where do I set the ColHead: field below up? I think I set the
"W0",W1"
etc
up in the ColumnHeadings in the crosstab query properties.

Can I use the query for the source of the subreport or should I set
up
a
separate report with the crosstab query as the sorce?

If I try and run a report with the crosstab as the source, I
received
the
followng message after enter 1/1/05 for the prompt: "This expression
is
typed
incorrectly, or it is too complex to be evaluated. For example, a
numeric
expression may contain too many complicated elements. Try
simplifying
the
expression by assigning parts of the expression to variables. "

Is there anyway to send this database to you?

John

:

The switchboard form must be open when running the query/report.

I would use relative dates for column headings. For instance if you
had a
date value in a text box "txtEndDate" on your form, you could set
the
column
headings expession to:
ColHead:"W" & DateDiff("ww",[CalDate],
[Forms]![Switchboard]![TxtEndDate])

Set the Query->Parameter
[Forms]![Switchboard]![TxtEndDate] DateTime

Set the column Headings property to:
"W0","W1","W2","W3","W4"

--
Duane Hookom
MS Access MVP


Duane

If I run the crosstab query from the database window, it prompts
once
as
[Forms]![Switchboard]![SelectMonth] and works fine.

PARAMETERS [Forms]![Switchboard]![SelectMonth] Text ( 255 );
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON
TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

When I run the report it prompts twice showing
[Forms]![Switchboard]![SelectMonth] in the title then the
following
error
comes up: "You can't use a pass-through query or an
non-fixed-column
crosstab
query as a record source for a subform or subreport. Before you
bind
the
subform or subreport to a crosstab query, set the query's
ColumnHeadings
peoperty."

After reading help, I have to put the exact field names in the
ColumnHeadings field. How can I run it for a selected month. The
output
titles for July example would be "Type", "7/3/2005", "7/10/2005",
"7/17/2005", "7/24/2005", "7/31/2005" but for August would be
"Type",
"8/7/2005", "8/14/2005", "8/21/2005", "8/28/2005".

John

:

Change the parameter type to "Text".

--
Duane Hookom
MS Access MVP


Duane

I am using the monthname of the month, a string instead of the
number
of
the
month which would be an integer. Here is what the query says
with
the
parameter:

Select Query - QryMonthCurr
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON
TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

Crosstab Query
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate;

John

:

This question gets asked and answered here quite often. You
must
enter
the
parameter data types into the Query->Parameters:
Forms!SwitchBoard!SelectMonth Integer
--
Duane Hookom
MS Access MVP


Duane

I have tried using a from combo box for this and I get the
following
error
message: "The Microsoft Jet database engine does not
recognize
'Forms!SwitchBoard!SelectMonth' as a valid field name or
expression". I
have
used the "Build" function in the query to find the field on
the
form
instead
of typing it in myself.

John

:

If you have a control on a form "Forms!frmDates!txtDate",
you
might
be
able
to replace "Now" with "Forms!frmDates!txtDate".

However, you haven't shown us your SQL view of the
crosstabs.

--
Duane Hookom
MS Access MVP
--

message
I have an unbound report with 3 subreports. The source
for
all
the
subreports
are crosstab queries. The data for the crosstab queries
are
3
select
queries.
If I put month(now), month(now)-1, and month(now)-2 in
the
 
Duane

I have a Row Heading for the type, A column Heading for Date and a Sum value
for the amount. How can I also have a row heading for the month and type?
What I want as output would be:

QryMonthPrev2 & QryNewCrosstabPrev2 -> Subreport1
Type 5/1/05 5/8/05 5/15/05 5/22/05 5/29/05
A $100 $50 $20 $50 $75
B $200 $52 $25 $60 $50
C $150 $70 $21 $70 $60
D $101 $90 $15 $80 $80

QryMonthPrev1 & QryNewCrosstabPrev1 -> Subreport2
Type 6/5/05 6/12/05 6/19/05 6/26/05
A $150 $150 $120 $150
B $250 $152 $125 $160
C $170 $170 $121 $170
D $121 $190 $115 $180

QryMonthCurr & QryNewCrosstabCurr -> Subreport3
Type 7/3/05 7/10/05 7/17/05 7/24/05 7/31/05
A $100 $50 $20 $50 $75
B $200 $52 $25 $60 $50
C $150 $70 $21 $70 $60
D $101 $90 $15 $80 $80

I hope this explains better what I want as the output.

John

Duane Hookom said:
Why are you creating three separate crosstabs (one for each of three months)
when it seems that you should be able to add a month row heading to a single
crosstab?

--
Duane Hookom
MS Access MVP


jbruen said:
Duane

Below is the table. I'm trying to get a crosstab query so the Date/week is
the column, Type is the row and it's summed by the amount. Then I create
this
3 seperate times, showing types by Current Month by date/week on the first
line, showing types by Current Month -1 by date/week on the second line
and
showing types by Current Month -3 by date/week on the third line. This is
how
the 3 months would make up the sub reports.

CalDate Date/Time 8
Envelope Long Integer 4
Type Text 50
Amount Currency 8
CheckNumber Long Integer 4
Memo Memo -

John

Duane Hookom said:
I wish I knew what you had for tables and records as well as your desired
format/display of that data in your report.

--
Duane Hookom
MS Access MVP


Duane

Below are the two queries. After I select the dates in the 3 combo
boxes I
receive the following error message: "There is an error executing the
command" when running from the switchboard. If I try and open the
report
from
the database window, I get prompted for 1 date and receive the
following
error message: "This expression is typed incorrectly, or it is too
complex
to
be evaluated. For example, a numeric expression may contain too many
complicated elements. Try simplifying the expression by assigning parts
of
the expression to variables. "

How should the queries look when I get finished?

Where do I set the column headings expession to: ColHead:"W" &
DateDiff("ww",CalDate], [Forms]![Switchboard]![FirstDate]) ?

---1st Select Query - QryMonthCurr
PARAMETERS [Forms]![Switchboard]![FirstDate] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![FirstDate]));

---2nd Select Query - QryMonthPrev1
PARAMETERS [Forms]![Switchboard]![SelectMonth] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SecondDate]));

---3rd Select Query - QryMonthPrev2
PARAMETERS [Forms]![Switchboard]![SelectMonth] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![ThirdDate]));

--1st CrossTab Query - QryNewCrosstabCurr
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate In ("W0","W1","W2","w3","w4","w5");

--2nd CrossTab Query - QryNewCrosstabPrev1
TRANSFORM Sum(QryMonthPrev1.Amount) AS SumOfAmount
SELECT QryMonthPrev1.Type
FROM QryMonthPrev1
GROUP BY QryMonthPrev1.Type
ORDER BY QryMonthPrev1.Type, QryMonthPrev1.CalDate
PIVOT QryMonthPrev1.CalDate In ("W0","W1","W2","w3","w4","w5");

--3rd CrossTab Query - QryNewCrosstabPrev2
TRANSFORM Sum(QryMonthPrev2.Amount) AS SumOfAmount
SELECT QryMonthPrev2.Type
FROM QryMonthPrev2
GROUP BY QryMonthPrev2.Type
ORDER BY QryMonthPrev2.Type, QryMonthPrev2.CalDate
PIVOT QryMonthPrev2.CalDate In ("W0","W1","W2","w3","w4","w5");

I tried this query since I could not figure out how I was going to get
the
whole month with the date selection you were showing me:

PARAMETERS [Forms]![Switchboard]![FirstDate] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount, TabOfferingType.Type,
Month([caldate]) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type =
TabOfferings.Type
WHERE (((Month([caldate]))=Month([Forms]![Switchboard]![FirstDate])));

When I run the crosstab I still get the message:"This expression is
typed
incorrectly, or it is too complex to be evaluated. For example, a
numeric
expression may contain too many complicated elements. Try simplifying
the
expression by assigning parts of the expression to variables."

John


:

You use the "ColHead:"W" & DateDiff("ww",[CalDate..." as the column in
your
query grid that generates the column headings.

If you follow my instructions, you can use the crosstab as the record
source
of a subreport.

Just post the SQL view of your best attempt at the solution.

--
Duane Hookom
MS Access MVP


Duane

Where do I set the ColHead: field below up? I think I set the
"W0",W1"
etc
up in the ColumnHeadings in the crosstab query properties.

Can I use the query for the source of the subreport or should I set
up
a
separate report with the crosstab query as the sorce?

If I try and run a report with the crosstab as the source, I
received
the
followng message after enter 1/1/05 for the prompt: "This expression
is
typed
incorrectly, or it is too complex to be evaluated. For example, a
numeric
expression may contain too many complicated elements. Try
simplifying
the
expression by assigning parts of the expression to variables. "

Is there anyway to send this database to you?

John

:

The switchboard form must be open when running the query/report.

I would use relative dates for column headings. For instance if you
had a
date value in a text box "txtEndDate" on your form, you could set
the
column
headings expession to:
ColHead:"W" & DateDiff("ww",[CalDate],
[Forms]![Switchboard]![TxtEndDate])

Set the Query->Parameter
[Forms]![Switchboard]![TxtEndDate] DateTime

Set the column Headings property to:
"W0","W1","W2","W3","W4"

--
Duane Hookom
MS Access MVP


Duane

If I run the crosstab query from the database window, it prompts
once
as
[Forms]![Switchboard]![SelectMonth] and works fine.

PARAMETERS [Forms]![Switchboard]![SelectMonth] Text ( 255 );
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON
TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

When I run the report it prompts twice showing
[Forms]![Switchboard]![SelectMonth] in the title then the
following
error
comes up: "You can't use a pass-through query or an
non-fixed-column
crosstab
query as a record source for a subform or subreport. Before you
bind
the
subform or subreport to a crosstab query, set the query's
ColumnHeadings
peoperty."

After reading help, I have to put the exact field names in the
ColumnHeadings field. How can I run it for a selected month. The
output
titles for July example would be "Type", "7/3/2005", "7/10/2005",
"7/17/2005", "7/24/2005", "7/31/2005" but for August would be
"Type",
"8/7/2005", "8/14/2005", "8/21/2005", "8/28/2005".

John

:

Change the parameter type to "Text".

--
Duane Hookom
MS Access MVP


Duane

I am using the monthname of the month, a string instead of the
number
of
the
month which would be an integer. Here is what the query says
with
the
parameter:

Select Query - QryMonthCurr
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON
TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

Crosstab Query
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate;

John

"Duane Hookom" wrote:
 
I would create a small function that returned the week of the month like:
Function GetWeekOfMth(pDate As Date) As Integer
Dim datFirst As Date
datFirst = pDate - Day(pDate) + 1
GetWeekOfMth = DateDiff("ww", datFirst, pDate) + 1
End Function

You could then use this function in your column heading expression like:
ColHead:GetWeekOfMth([caldate])
This would allow you to group by week as columns and month as row headings.
--
Duane Hookom
MS Access MVP
--

jbruen said:
Duane

I have a Row Heading for the type, A column Heading for Date and a Sum
value
for the amount. How can I also have a row heading for the month and type?
What I want as output would be:

QryMonthPrev2 & QryNewCrosstabPrev2 -> Subreport1
Type 5/1/05 5/8/05 5/15/05 5/22/05 5/29/05
A $100 $50 $20 $50
$75
B $200 $52 $25 $60
$50
C $150 $70 $21 $70
$60
D $101 $90 $15 $80
$80

QryMonthPrev1 & QryNewCrosstabPrev1 -> Subreport2
Type 6/5/05 6/12/05 6/19/05 6/26/05
A $150 $150 $120 $150
B $250 $152 $125 $160
C $170 $170 $121 $170
D $121 $190 $115 $180

QryMonthCurr & QryNewCrosstabCurr -> Subreport3
Type 7/3/05 7/10/05 7/17/05 7/24/05 7/31/05
A $100 $50 $20 $50
$75
B $200 $52 $25 $60
$50
C $150 $70 $21 $70
$60
D $101 $90 $15 $80
$80

I hope this explains better what I want as the output.

John

Duane Hookom said:
Why are you creating three separate crosstabs (one for each of three
months)
when it seems that you should be able to add a month row heading to a
single
crosstab?

--
Duane Hookom
MS Access MVP


jbruen said:
Duane

Below is the table. I'm trying to get a crosstab query so the Date/week
is
the column, Type is the row and it's summed by the amount. Then I
create
this
3 seperate times, showing types by Current Month by date/week on the
first
line, showing types by Current Month -1 by date/week on the second line
and
showing types by Current Month -3 by date/week on the third line. This
is
how
the 3 months would make up the sub reports.

CalDate Date/Time 8
Envelope Long Integer 4
Type Text 50
Amount Currency 8
CheckNumber Long Integer 4
Memo Memo -

John

:

I wish I knew what you had for tables and records as well as your
desired
format/display of that data in your report.

--
Duane Hookom
MS Access MVP


Duane

Below are the two queries. After I select the dates in the 3 combo
boxes I
receive the following error message: "There is an error executing
the
command" when running from the switchboard. If I try and open the
report
from
the database window, I get prompted for 1 date and receive the
following
error message: "This expression is typed incorrectly, or it is too
complex
to
be evaluated. For example, a numeric expression may contain too many
complicated elements. Try simplifying the expression by assigning
parts
of
the expression to variables. "

How should the queries look when I get finished?

Where do I set the column headings expession to: ColHead:"W" &
DateDiff("ww",CalDate], [Forms]![Switchboard]![FirstDate]) ?

---1st Select Query - QryMonthCurr
PARAMETERS [Forms]![Switchboard]![FirstDate] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![FirstDate]));

---2nd Select Query - QryMonthPrev1
PARAMETERS [Forms]![Switchboard]![SelectMonth] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SecondDate]));

---3rd Select Query - QryMonthPrev2
PARAMETERS [Forms]![Switchboard]![SelectMonth] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![ThirdDate]));

--1st CrossTab Query - QryNewCrosstabCurr
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate In ("W0","W1","W2","w3","w4","w5");

--2nd CrossTab Query - QryNewCrosstabPrev1
TRANSFORM Sum(QryMonthPrev1.Amount) AS SumOfAmount
SELECT QryMonthPrev1.Type
FROM QryMonthPrev1
GROUP BY QryMonthPrev1.Type
ORDER BY QryMonthPrev1.Type, QryMonthPrev1.CalDate
PIVOT QryMonthPrev1.CalDate In ("W0","W1","W2","w3","w4","w5");

--3rd CrossTab Query - QryNewCrosstabPrev2
TRANSFORM Sum(QryMonthPrev2.Amount) AS SumOfAmount
SELECT QryMonthPrev2.Type
FROM QryMonthPrev2
GROUP BY QryMonthPrev2.Type
ORDER BY QryMonthPrev2.Type, QryMonthPrev2.CalDate
PIVOT QryMonthPrev2.CalDate In ("W0","W1","W2","w3","w4","w5");

I tried this query since I could not figure out how I was going to
get
the
whole month with the date selection you were showing me:

PARAMETERS [Forms]![Switchboard]![FirstDate] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
Month([caldate]) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((Month([caldate]))=Month([Forms]![Switchboard]![FirstDate])));

When I run the crosstab I still get the message:"This expression is
typed
incorrectly, or it is too complex to be evaluated. For example, a
numeric
expression may contain too many complicated elements. Try
simplifying
the
expression by assigning parts of the expression to variables."

John


:

You use the "ColHead:"W" & DateDiff("ww",[CalDate..." as the column
in
your
query grid that generates the column headings.

If you follow my instructions, you can use the crosstab as the
record
source
of a subreport.

Just post the SQL view of your best attempt at the solution.

--
Duane Hookom
MS Access MVP


Duane

Where do I set the ColHead: field below up? I think I set the
"W0",W1"
etc
up in the ColumnHeadings in the crosstab query properties.

Can I use the query for the source of the subreport or should I
set
up
a
separate report with the crosstab query as the sorce?

If I try and run a report with the crosstab as the source, I
received
the
followng message after enter 1/1/05 for the prompt: "This
expression
is
typed
incorrectly, or it is too complex to be evaluated. For example, a
numeric
expression may contain too many complicated elements. Try
simplifying
the
expression by assigning parts of the expression to variables. "

Is there anyway to send this database to you?

John

:

The switchboard form must be open when running the query/report.

I would use relative dates for column headings. For instance if
you
had a
date value in a text box "txtEndDate" on your form, you could
set
the
column
headings expession to:
ColHead:"W" & DateDiff("ww",[CalDate],
[Forms]![Switchboard]![TxtEndDate])

Set the Query->Parameter
[Forms]![Switchboard]![TxtEndDate] DateTime

Set the column Headings property to:
"W0","W1","W2","W3","W4"

--
Duane Hookom
MS Access MVP


Duane

If I run the crosstab query from the database window, it
prompts
once
as
[Forms]![Switchboard]![SelectMonth] and works fine.

PARAMETERS [Forms]![Switchboard]![SelectMonth] Text ( 255 );
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON
TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

When I run the report it prompts twice showing
[Forms]![Switchboard]![SelectMonth] in the title then the
following
error
comes up: "You can't use a pass-through query or an
non-fixed-column
crosstab
query as a record source for a subform or subreport. Before
you
bind
the
subform or subreport to a crosstab query, set the query's
ColumnHeadings
peoperty."

After reading help, I have to put the exact field names in the
ColumnHeadings field. How can I run it for a selected month.
The
output
titles for July example would be "Type", "7/3/2005",
"7/10/2005",
"7/17/2005", "7/24/2005", "7/31/2005" but for August would be
"Type",
"8/7/2005", "8/14/2005", "8/21/2005", "8/28/2005".

John

:

Change the parameter type to "Text".

--
Duane Hookom
MS Access MVP


Duane

I am using the monthname of the month, a string instead of
the
number
of
the
month which would be an integer. Here is what the query
says
with
the
parameter:

Select Query - QryMonthCurr
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON
TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SelectMonth]));

Crosstab Query
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate;

John

"Duane Hookom" wrote:
 
Duane

Since I'm confused on where to add the ColHead statement, I think I will
stick to the manual process which is working fine. This was the last crosstab
query I tried and it still did not work receiving this message"This
expression is typed incorrectly, or it is too complex to be evaluated. For
example, a numeric expression may contain too many complicated elements. Try
simplifying the expression by assigning parts of the expression to
variables.":
PARAMETERS [Forms]![Switchboard]![FirstDate] Text ( 255 );
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
WHERE (((MonthName(Month([caldate])))=[Forms]![Switchboard]![FirstDate]))
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate In (GetWeekOfMth([caldate]));


John

Duane Hookom said:
I would create a small function that returned the week of the month like:
Function GetWeekOfMth(pDate As Date) As Integer
Dim datFirst As Date
datFirst = pDate - Day(pDate) + 1
GetWeekOfMth = DateDiff("ww", datFirst, pDate) + 1
End Function

You could then use this function in your column heading expression like:
ColHead:GetWeekOfMth([caldate])
This would allow you to group by week as columns and month as row headings.
--
Duane Hookom
MS Access MVP
--

jbruen said:
Duane

I have a Row Heading for the type, A column Heading for Date and a Sum
value
for the amount. How can I also have a row heading for the month and type?
What I want as output would be:

QryMonthPrev2 & QryNewCrosstabPrev2 -> Subreport1
Type 5/1/05 5/8/05 5/15/05 5/22/05 5/29/05
A $100 $50 $20 $50
$75
B $200 $52 $25 $60
$50
C $150 $70 $21 $70
$60
D $101 $90 $15 $80
$80

QryMonthPrev1 & QryNewCrosstabPrev1 -> Subreport2
Type 6/5/05 6/12/05 6/19/05 6/26/05
A $150 $150 $120 $150
B $250 $152 $125 $160
C $170 $170 $121 $170
D $121 $190 $115 $180

QryMonthCurr & QryNewCrosstabCurr -> Subreport3
Type 7/3/05 7/10/05 7/17/05 7/24/05 7/31/05
A $100 $50 $20 $50
$75
B $200 $52 $25 $60
$50
C $150 $70 $21 $70
$60
D $101 $90 $15 $80
$80

I hope this explains better what I want as the output.

John

Duane Hookom said:
Why are you creating three separate crosstabs (one for each of three
months)
when it seems that you should be able to add a month row heading to a
single
crosstab?

--
Duane Hookom
MS Access MVP


Duane

Below is the table. I'm trying to get a crosstab query so the Date/week
is
the column, Type is the row and it's summed by the amount. Then I
create
this
3 seperate times, showing types by Current Month by date/week on the
first
line, showing types by Current Month -1 by date/week on the second line
and
showing types by Current Month -3 by date/week on the third line. This
is
how
the 3 months would make up the sub reports.

CalDate Date/Time 8
Envelope Long Integer 4
Type Text 50
Amount Currency 8
CheckNumber Long Integer 4
Memo Memo -

John

:

I wish I knew what you had for tables and records as well as your
desired
format/display of that data in your report.

--
Duane Hookom
MS Access MVP


Duane

Below are the two queries. After I select the dates in the 3 combo
boxes I
receive the following error message: "There is an error executing
the
command" when running from the switchboard. If I try and open the
report
from
the database window, I get prompted for 1 date and receive the
following
error message: "This expression is typed incorrectly, or it is too
complex
to
be evaluated. For example, a numeric expression may contain too many
complicated elements. Try simplifying the expression by assigning
parts
of
the expression to variables. "

How should the queries look when I get finished?

Where do I set the column headings expession to: ColHead:"W" &
DateDiff("ww",CalDate], [Forms]![Switchboard]![FirstDate]) ?

---1st Select Query - QryMonthCurr
PARAMETERS [Forms]![Switchboard]![FirstDate] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![FirstDate]));

---2nd Select Query - QryMonthPrev1
PARAMETERS [Forms]![Switchboard]![SelectMonth] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SecondDate]));

---3rd Select Query - QryMonthPrev2
PARAMETERS [Forms]![Switchboard]![SelectMonth] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![ThirdDate]));

--1st CrossTab Query - QryNewCrosstabCurr
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate In ("W0","W1","W2","w3","w4","w5");

--2nd CrossTab Query - QryNewCrosstabPrev1
TRANSFORM Sum(QryMonthPrev1.Amount) AS SumOfAmount
SELECT QryMonthPrev1.Type
FROM QryMonthPrev1
GROUP BY QryMonthPrev1.Type
ORDER BY QryMonthPrev1.Type, QryMonthPrev1.CalDate
PIVOT QryMonthPrev1.CalDate In ("W0","W1","W2","w3","w4","w5");

--3rd CrossTab Query - QryNewCrosstabPrev2
TRANSFORM Sum(QryMonthPrev2.Amount) AS SumOfAmount
SELECT QryMonthPrev2.Type
FROM QryMonthPrev2
GROUP BY QryMonthPrev2.Type
ORDER BY QryMonthPrev2.Type, QryMonthPrev2.CalDate
PIVOT QryMonthPrev2.CalDate In ("W0","W1","W2","w3","w4","w5");

I tried this query since I could not figure out how I was going to
get
the
whole month with the date selection you were showing me:

PARAMETERS [Forms]![Switchboard]![FirstDate] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
Month([caldate]) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((Month([caldate]))=Month([Forms]![Switchboard]![FirstDate])));

When I run the crosstab I still get the message:"This expression is
typed
incorrectly, or it is too complex to be evaluated. For example, a
numeric
expression may contain too many complicated elements. Try
simplifying
the
expression by assigning parts of the expression to variables."

John


:

You use the "ColHead:"W" & DateDiff("ww",[CalDate..." as the column
in
your
query grid that generates the column headings.

If you follow my instructions, you can use the crosstab as the
record
source
of a subreport.

Just post the SQL view of your best attempt at the solution.

--
Duane Hookom
MS Access MVP


Duane

Where do I set the ColHead: field below up? I think I set the
"W0",W1"
etc
up in the ColumnHeadings in the crosstab query properties.

Can I use the query for the source of the subreport or should I
set
up
a
separate report with the crosstab query as the sorce?

If I try and run a report with the crosstab as the source, I
received
the
followng message after enter 1/1/05 for the prompt: "This
expression
is
typed
incorrectly, or it is too complex to be evaluated. For example, a
numeric
expression may contain too many complicated elements. Try
simplifying
the
expression by assigning parts of the expression to variables. "

Is there anyway to send this database to you?

John

:

The switchboard form must be open when running the query/report.

I would use relative dates for column headings. For instance if
you
had a
date value in a text box "txtEndDate" on your form, you could
set
the
column
headings expession to:
ColHead:"W" & DateDiff("ww",[CalDate],
[Forms]![Switchboard]![TxtEndDate])

Set the Query->Parameter
[Forms]![Switchboard]![TxtEndDate] DateTime

Set the column Headings property to:
"W0","W1","W2","W3","W4"

--
Duane Hookom
MS Access MVP


Duane
 
The colhead would use the function as the column heading.

PARAMETERS [Forms]![Switchboard]![FirstDate] Text ( 255 );
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
WHERE (((MonthName(Month([caldate])))=[Forms]![Switchboard]![FirstDate]))
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT GetWeekOfMth([caldate]);

--
Duane Hookom
MS Access MVP


jbruen said:
Duane

Since I'm confused on where to add the ColHead statement, I think I will
stick to the manual process which is working fine. This was the last
crosstab
query I tried and it still did not work receiving this message"This
expression is typed incorrectly, or it is too complex to be evaluated. For
example, a numeric expression may contain too many complicated elements.
Try
simplifying the expression by assigning parts of the expression to
variables.":
PARAMETERS [Forms]![Switchboard]![FirstDate] Text ( 255 );
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
WHERE (((MonthName(Month([caldate])))=[Forms]![Switchboard]![FirstDate]))
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate In (GetWeekOfMth([caldate]));


John

Duane Hookom said:
I would create a small function that returned the week of the month like:
Function GetWeekOfMth(pDate As Date) As Integer
Dim datFirst As Date
datFirst = pDate - Day(pDate) + 1
GetWeekOfMth = DateDiff("ww", datFirst, pDate) + 1
End Function

You could then use this function in your column heading expression like:
ColHead:GetWeekOfMth([caldate])
This would allow you to group by week as columns and month as row
headings.
--
Duane Hookom
MS Access MVP
--

jbruen said:
Duane

I have a Row Heading for the type, A column Heading for Date and a Sum
value
for the amount. How can I also have a row heading for the month and
type?
What I want as output would be:

QryMonthPrev2 & QryNewCrosstabPrev2 -> Subreport1
Type 5/1/05 5/8/05 5/15/05 5/22/05 5/29/05
A $100 $50 $20 $50
$75
B $200 $52 $25 $60
$50
C $150 $70 $21 $70
$60
D $101 $90 $15 $80
$80

QryMonthPrev1 & QryNewCrosstabPrev1 -> Subreport2
Type 6/5/05 6/12/05 6/19/05 6/26/05
A $150 $150 $120 $150
B $250 $152 $125 $160
C $170 $170 $121 $170
D $121 $190 $115 $180

QryMonthCurr & QryNewCrosstabCurr -> Subreport3
Type 7/3/05 7/10/05 7/17/05 7/24/05 7/31/05
A $100 $50 $20 $50
$75
B $200 $52 $25 $60
$50
C $150 $70 $21 $70
$60
D $101 $90 $15 $80
$80

I hope this explains better what I want as the output.

John

:

Why are you creating three separate crosstabs (one for each of three
months)
when it seems that you should be able to add a month row heading to a
single
crosstab?

--
Duane Hookom
MS Access MVP


Duane

Below is the table. I'm trying to get a crosstab query so the
Date/week
is
the column, Type is the row and it's summed by the amount. Then I
create
this
3 seperate times, showing types by Current Month by date/week on the
first
line, showing types by Current Month -1 by date/week on the second
line
and
showing types by Current Month -3 by date/week on the third line.
This
is
how
the 3 months would make up the sub reports.

CalDate Date/Time 8
Envelope Long Integer 4
Type Text 50
Amount Currency 8
CheckNumber Long Integer 4
Memo Memo -

John

:

I wish I knew what you had for tables and records as well as your
desired
format/display of that data in your report.

--
Duane Hookom
MS Access MVP


Duane

Below are the two queries. After I select the dates in the 3
combo
boxes I
receive the following error message: "There is an error executing
the
command" when running from the switchboard. If I try and open the
report
from
the database window, I get prompted for 1 date and receive the
following
error message: "This expression is typed incorrectly, or it is
too
complex
to
be evaluated. For example, a numeric expression may contain too
many
complicated elements. Try simplifying the expression by assigning
parts
of
the expression to variables. "

How should the queries look when I get finished?

Where do I set the column headings expession to: ColHead:"W" &
DateDiff("ww",CalDate], [Forms]![Switchboard]![FirstDate]) ?

---1st Select Query - QryMonthCurr
PARAMETERS [Forms]![Switchboard]![FirstDate] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON
TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![FirstDate]));

---2nd Select Query - QryMonthPrev1
PARAMETERS [Forms]![Switchboard]![SelectMonth] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON
TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![SecondDate]));

---3rd Select Query - QryMonthPrev2
PARAMETERS [Forms]![Switchboard]![SelectMonth] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
MonthName(Month([caldate])) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON
TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((MonthName(Month([caldate])))=[Forms]![Switchboard]![ThirdDate]));

--1st CrossTab Query - QryNewCrosstabCurr
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT QryMonthCurr.CalDate In ("W0","W1","W2","w3","w4","w5");

--2nd CrossTab Query - QryNewCrosstabPrev1
TRANSFORM Sum(QryMonthPrev1.Amount) AS SumOfAmount
SELECT QryMonthPrev1.Type
FROM QryMonthPrev1
GROUP BY QryMonthPrev1.Type
ORDER BY QryMonthPrev1.Type, QryMonthPrev1.CalDate
PIVOT QryMonthPrev1.CalDate In ("W0","W1","W2","w3","w4","w5");

--3rd CrossTab Query - QryNewCrosstabPrev2
TRANSFORM Sum(QryMonthPrev2.Amount) AS SumOfAmount
SELECT QryMonthPrev2.Type
FROM QryMonthPrev2
GROUP BY QryMonthPrev2.Type
ORDER BY QryMonthPrev2.Type, QryMonthPrev2.CalDate
PIVOT QryMonthPrev2.CalDate In ("W0","W1","W2","w3","w4","w5");

I tried this query since I could not figure out how I was going
to
get
the
whole month with the date selection you were showing me:

PARAMETERS [Forms]![Switchboard]![FirstDate] DateTime;
SELECT TabOfferings.CalDate, TabOfferings.Amount,
TabOfferingType.Type,
Month([caldate]) AS [Month]
FROM TabOfferingType INNER JOIN TabOfferings ON
TabOfferingType.Type
=
TabOfferings.Type
WHERE
(((Month([caldate]))=Month([Forms]![Switchboard]![FirstDate])));

When I run the crosstab I still get the message:"This expression
is
typed
incorrectly, or it is too complex to be evaluated. For example, a
numeric
expression may contain too many complicated elements. Try
simplifying
the
expression by assigning parts of the expression to variables."

John


:

You use the "ColHead:"W" & DateDiff("ww",[CalDate..." as the
column
in
your
query grid that generates the column headings.

If you follow my instructions, you can use the crosstab as the
record
source
of a subreport.

Just post the SQL view of your best attempt at the solution.

--
Duane Hookom
MS Access MVP


Duane

Where do I set the ColHead: field below up? I think I set the
"W0",W1"
etc
up in the ColumnHeadings in the crosstab query properties.

Can I use the query for the source of the subreport or should
I
set
up
a
separate report with the crosstab query as the sorce?

If I try and run a report with the crosstab as the source, I
received
the
followng message after enter 1/1/05 for the prompt: "This
expression
is
typed
incorrectly, or it is too complex to be evaluated. For
example, a
numeric
expression may contain too many complicated elements. Try
simplifying
the
expression by assigning parts of the expression to variables.
"

Is there anyway to send this database to you?

John

:

The switchboard form must be open when running the
query/report.

I would use relative dates for column headings. For instance
if
you
had a
date value in a text box "txtEndDate" on your form, you could
set
the
column
headings expession to:
ColHead:"W" & DateDiff("ww",[CalDate],
[Forms]![Switchboard]![TxtEndDate])

Set the Query->Parameter
[Forms]![Switchboard]![TxtEndDate] DateTime

Set the column Headings property to:
"W0","W1","W2","W3","W4"

--
Duane Hookom
MS Access MVP


Duane
 
Duane

I put in exactly what you had and received the following error: You tried to
execute a query that does not include the specified expression
'QryMonthCurr.CalDate' as part of an aggregate function. I manually typed the
PIVOT line since I could not figure out how to get it in automatically.

PARAMETERS [Forms]![Switchboard]![FirstDate] Text ( 255 );
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
WHERE (((MonthName(Month([caldate])))=Forms!Switchboard!FirstDate))
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT GetWeekOfMth([caldate]);
 
The ORDER BY that includes CalDate came from your previous posting. Delete
QryMonthCurr.CalDate from the ORDER BY.

--
Duane Hookom
MS Access MVP


jbruen said:
Duane

I put in exactly what you had and received the following error: You tried
to
execute a query that does not include the specified expression
'QryMonthCurr.CalDate' as part of an aggregate function. I manually typed
the
PIVOT line since I could not figure out how to get it in automatically.

PARAMETERS [Forms]![Switchboard]![FirstDate] Text ( 255 );
TRANSFORM Sum(QryMonthCurr.Amount) AS SumOfAmount
SELECT QryMonthCurr.Type
FROM QryMonthCurr
WHERE (((MonthName(Month([caldate])))=Forms!Switchboard!FirstDate))
GROUP BY QryMonthCurr.Type
ORDER BY QryMonthCurr.Type, QryMonthCurr.CalDate
PIVOT GetWeekOfMth([caldate]);


jbruen said:
Duane

I have tried using a from combo box for this and I get the following
error
message: "The Microsoft Jet database engine does not recognize
'Forms!SwitchBoard!SelectMonth' as a valid field name or expression". I
have
used the "Build" function in the query to find the field on the form
instead
of typing it in myself.

John
 
Back
Top