| |
 |
|
| Computers Forum Index » Computer - Databases - MS Access » Can't figure out how to write this CrosTab properly -... |
|
Page 2 of 2 Goto page Previous 1, 2 |
|
| Author |
Message |
| sara... |
Posted: Tue Oct 27, 2009 12:43 am |
|
|
|
Guest
|
On Oct 26, 8:08 pm, Chuck Grimsby <cgat... at (no spam) gmail.com> wrote:
Quote: On Oct 25, 12:15 pm, sara <saraqp... at (no spam) yahoo.com> wrote:
On Oct 25, 12:56 pm, Chuck Grimsby <cgat... at (no spam) gmail.com> wrote:
On Oct 23, 3:17 pm, sara <saraqp... at (no spam) yahoo.com> wrote:
Hi -
I am trying to get a report that will show 12 months of data for a
Department (or less if fewer than 12 months are on file), BUT the user
is only supplying the Ending Fiscal year and Fiscal Month.
I have a query that gives me all the data - perfectly - but I think I
need a crosstab to get the data on the report. If there's a better
way, I'm open to it!
SO, the report would be:
"Values for the 12 months ending FY 2009 Fiscal Month 7"
FY 08-9 FY08-10 FY08-11 FY08-12 FY09-1 FY09-2
FY09-3.......FY09-7 Avg Total
Dept $$ $$ $$ $$ $
$ $$ $$ $$ $$ $$
I have a crosstab but when I go to do the report, I realize the Column
Headings are "fixed" - they say "FY08-9" etc. Where I need the
headings on the report to be dynamic - they would change with every
report, based on the user's entry parameter.
I figure I could make the headings on the report be like "DateAdd "m"
-12,(entry info)",
"DateAdd "m" -11 (entry info)" - I could probably figure that out.
But I can't get the crosstab to sort properly - no matter what I do!
Obviously the data on the report has to appear under the proper
heading.
I tried to think of a way to use a temporary table to help me - I'm
just stuck! I don't believe this should be all that hard but I've
been trying for the better part of 3 days now and it's time to ask for
help!
Thank you -
Sara
Use the IN clause of the Pivot Table statement to do the ordering.- Hide quoted text -
- Show quoted text -
Thanks, Chuck. But I am doing a Crosstab Query, not a Pivot Table.
Unless maybe they are the same name? Anyway, I don't see where to put
the IN clause and I don't see anything in Help or in Google posts that
gives me any info.
can you possibly be a little more specific for me here?
Thank you -
sara
Sorry for the confusion, they are the same thing. PIVOT is the SQL
statement. If you're working in the "Design" view, then you won't see
it. Switch to SQL view and you will. (I do most of my work in the
SQL view these days, and I (sadly) forgot that you probably didn't.
The term "CrossTab" is something that exists only in Access.- Hide quoted text -
- Show quoted text -
Thank you for the clarification. |
|
|
| Back to top |
|
|
|
| sara... |
Posted: Tue Oct 27, 2009 12:49 am |
|
|
|
Guest
|
On Oct 26, 6:42 pm, Marshall Barton <marshbar... at (no spam) wowway.com> wrote:
Quote: sara wrote:
On Oct 26, 12:35 pm, Marshall Barton <marshbar... at (no spam) wowway.com> wrote:
sara wrote:
Thank you, Marsh. This does give me the numbers in the proper
sequence, but I don't know which month the numbers represent! I don't
know how to get that. I've tried tackingthe FiscalYear and Month at
the end of the above (without the format), but it doesn't .
Then it occurred to me to use the "DateSerial" that Bob formulated for
me - use that as the column heading and I think that may work!
At least gives me the next step. I have a date - the first of the
month. I just have to figure out how to turn that into YYMM (Fiscal
yr and Mo) in the report....which I should be able to do with a format
statement (I'm hoping) OR do it in the final query I write for the
report.
I think the heading text boxes would each use an expression
something like:
=DateSerial(Forms.frmChooseAccount.cboFiscalYear,
Forms.frmChooseAccount.cboFiscalMonth - 12, 1)
=DateSerial(Forms.frmChooseAccount.cboFiscalYear,
Forms.frmChooseAccount.cboFiscalMonth - 11, 1)
. . .
=DateSerial(Forms.frmChooseAccount.cboFiscalYear,
Forms.frmChooseAccount.cboFiscalMonth - 1, 1)
Set the text box's Format property to display the date the
way you want to see it.
--
Marsh
I hope I didn't speak too soon,....While I am able to get the data on
a report, I don't see how to get from the Crosstab query into a Temp
Table - dynamically. I know how to put the code for a query into VBA
(I struggle, but I usually manage to get it done!), but I don't even
see how this will help me here.
I have the crosstab which creates columns with the names "7/1/2009"
"8/1/2009". I need to get that into a temp table (or other query) but
the field names will be different every time.
Does this make sense? Once again - I fell I'm really close, but just
not there. Like I have step 1 and 3, but can't get step 2.
Why would you want to put that into a table? You should be
able to run the report's crosstab query whenever you want to
see the data.
I can't see why you would need to, but if you really feel
it's necessay to put that data in another table, can you use
the crosstab query as the source of a make table or append
query?
--
Marsh- Hide quoted text -
- Show quoted text -
Well I reviewed the article from Salad and see you CAN use a crosstab
as a data source for a report,which I did get to work. But the field
names (here we go again!) in the report do not match the field names
in the query, so when the input date changes, and I go to run the
report, I get "Microsoft Jet database engine does not recognize " as a
valid fieldname or expression". I figured this out to be the field
name on the report is not in the query.
SO, the question is how can I have a dynamic field name as the column
heading of the crosstab query? Maybe get it to be a number somehow,
which would always be there and then still be able to use the
DateSerial formula for the headers? I do have to make sure the data in
each column is correct....
sara |
|
|
| Back to top |
|
|
|
| Bob Quintal... |
Posted: Tue Oct 27, 2009 1:06 am |
|
|
|
Guest
|
sara <saraqpost at (no spam) yahoo.com> wrote in
news:99f10e56-13b5-4194-b131-a68e3ec68dde at (no spam) m11g2000vbl.googlegroups.co
m:
Quote: On Oct 26, 7:00 am, sara <saraqp... at (no spam) yahoo.com> wrote:
On Oct 26, 12:44 am, Marshall Barton <marshbar... at (no spam) wowway.com
wrote:
sara wrote:
[]
I tried this and I'm still not getting the "right" order; I
think it's when I switch years.
[]
I expect to see 12, 11, 10, 9 8, 7, 6, 5, 4, 3, 2, 1 (I put 12
- instead of 13 - I have to work that one out myself for a
bit to figure out which number is right!)
But I'm seeing: 9, 8, 7, 6, 5, 4, 3,2, 12, 11, 10,1
Try it without using the Format function. Format always
results in a text string, which sort the way you are seeing.
--
Marsh
Thank you, Marsh. This does give me the numbers in the proper
sequence, but I don't know which month the numbers represent! I
don't know how to get that. I've tried tackingthe FiscalYear and
Month at the end of the above (without the format), but it
doesn't . Then it occurred to me to use the "DateSerial" that Bob
formulated for me - use that as the column heading and I think
that may work!
At least gives me the next step. I have a date - the first of
the month. I just have to figure out how to turn that into YYMM
(Fiscal yr and Mo) in the report....which I should be able to do
with a format statement (I'm hoping) OR do it in the final query
I write for the report.
Do you think that will work? I will try this approach later this
morning.
Many thanks - I'm getting there!
sara- Hide quoted text -
- Show quoted text -
I've tried all I can think of and I'm nowhere. I need the user to
enter FY and Fiscal Month (each chosen from combo boxes on the
form) and show the prior 12 months' data, with the proper
heading, on the report. Lost!
Thanks
Sara
You do not want to use e.g. 2009-10 as a column header in the query
feeding the report, because next month you will have a new column to
add and an old column to delete and the other columns will all need
to be moved. .
The query takes the data from the form to generate numbers from 1 to
12. (or 0 to 11)... That same form data can be used in the report to
calculate the headers for the report. The textboxes get their data
from the fields named 1 to 12.
--
Bob Quintal
PA is y I've altered my email address. |
|
|
| Back to top |
|
|
|
| Bob Quintal... |
Posted: Tue Oct 27, 2009 1:09 am |
|
|
|
Guest
|
Marshall Barton <marshbarton at (no spam) wowway.com> wrote in
news:g1aae5luqscd9l9r1flenl6sc52dn41osh at (no spam) 4ax.com:
Quote: sara wrote:
[]
I tried this and I'm still not getting the "right" order; I think
it's when I switch years.
[]
I expect to see 12, 11, 10, 9 8, 7, 6, 5, 4, 3, 2, 1 (I put 12 -
instead of 13 - I have to work that one out myself for a bit to
figure out which number is right!)
But I'm seeing: 9, 8, 7, 6, 5, 4, 3,2, 12, 11, 10,1
Try it without using the Format function. Format always
results in a text string, which sort the way you are seeing.
--
Marsh
Or debug my use of the format function, I forgot to put quotes around
the format string "00".
It should return 01, 02, 03,... 09, 10,11, 12 which will sort
correctly.
--
Bob Quintal
PA is y I've altered my email address. |
|
|
| Back to top |
|
|
|
| sara... |
Posted: Tue Oct 27, 2009 1:10 am |
|
|
|
Guest
|
On Oct 26, 5:06 pm, Bob Quintal <rquin... at (no spam) sPAmpatico.ca> wrote:
Quote: sara <saraqp... at (no spam) yahoo.com> wrote innews:99f10e56-13b5-4194-b131-a68e3ec68dde at (no spam) m11g2000vbl.googlegroups.co
m:
On Oct 26, 7:00 am, sara <saraqp... at (no spam) yahoo.com> wrote:
On Oct 26, 12:44 am, Marshall Barton <marshbar... at (no spam) wowway.com
wrote:
sara wrote:
[]
I tried this and I'm still not getting the "right" order; I
think it's when I switch years.
[]
I expect to see 12, 11, 10, 9 8, 7, 6, 5, 4, 3, 2, 1 (I put 12
- instead of 13 - I have to work that one out myself for a
bit to figure out which number is right!)
But I'm seeing: 9, 8, 7, 6, 5, 4, 3,2, 12, 11, 10,1
Try it without using the Format function. Format always
results in a text string, which sort the way you are seeing.
--
Marsh
Thank you, Marsh. This does give me the numbers in the proper
sequence, but I don't know which month the numbers represent! I
don't know how to get that. I've tried tackingthe FiscalYear and
Month at the end of the above (without the format), but it
doesn't . Then it occurred to me to use the "DateSerial" that Bob
formulated for me - use that as the column heading and I think
that may work!
At least gives me the next step. I have a date - the first of
the month. I just have to figure out how to turn that into YYMM
(Fiscal yr and Mo) in the report....which I should be able to do
with a format statement (I'm hoping) OR do it in the final query
I write for the report.
Do you think that will work? I will try this approach later this
morning.
Many thanks - I'm getting there!
sara- Hide quoted text -
- Show quoted text -
I've tried all I can think of and I'm nowhere. I need the user to
enter FY and Fiscal Month (each chosen from combo boxes on the
form) and show the prior 12 months' data, with the proper
heading, on the report. Lost!
Thanks
Sara
You do not want to use e.g. 2009-10 as a column header in the query
feeding the report, because next month you will have a new column to
add and an old column to delete and the other columns will all need
to be moved. .
The query takes the data from the form to generate numbers from 1 to
12. (or 0 to 11)... That same form data can be used in the report to
calculate the headers for the report. The textboxes get their data
from the fields named 1 to 12.
--
Bob Quintal
PA is y I've altered my email address.- Hide quoted text -
- Show quoted text -
This is what I was trying to do - just posted in my last message (at
least that was my intent). I put your formula back in my crosstab
and put the headings in order: 12, 10, 9, ....
Now, how do I konw the column headings that I created using what
Marshall suggested: =DateSerial([Forms].[frmReports].[cboFiscalYear],
[Forms].[frmReports].[cboFiscalMonth]-12,1) (-11, -10, etc) "match"
the data (col 12 as you suggested has to be the date associated with
the formula here)???
I actually got this working...in that I see data in all the columns,
etc. (I had to change your formula to start with 12- not 13-(12-
DateDiff("m",DateSerial([FiscalYr],[FiscalMonth],1),DateSerial([Forms].
[frmReports].[cboFiscalYear],[Forms].[frmReports].[cboFiscalMonth],
1)))). But how do I know the column "1" is really the one I have in
the formula (above)? I think it should be, based on it's using the
same fields, but I absolutely want to be certain.
I *might* actually have gotten this (with all your help!) |
|
|
| Back to top |
|
|
|
| Phil Stanton... |
Posted: Tue Oct 27, 2009 2:30 am |
|
|
|
Guest
|
Sorry, a bit comfusing about the Sep 09-Oct 09 field. It is actually a
calculated field and as the discount for both September & October are 0, the
query combines the 2 figures
Incidently, If I change the start of our financial year from September to
November, the query looks like this
RptPos TypeOfSpace SortOrder 1 3 4 5 6 7 8 9 10 11 12
1 Type of Space 10 Nov 09 - Dec 09 Jan 10 Feb 10 Mar 10 Apr 10 May 10
Jun 10 Jul 10 Aug 10 Sep 10 Oct 10
1 Discount 20 0.00% 8.33% 16.67% 25.00% 33.33% 41.67% 50.00% 58.33%
66.67% 75.00% 83.33%
2 Canoe Rack 30 £26.50 £24.29 £22.08 £19.88 £17.67 £15.46 £13.25
£11.04 £8.83 £6.63 £4.42
2 Dinghy Park 30 £52.50 £48.13 £43.75 £39.38 £35.00 £30.62 £26.25
£21.88 £17.50 £13.13 £8.75
2 Dinghy Rack 30 £31.50 £28.88 £26.25 £23.63 £21.00 £18.37 £15.75
£13.13 £10.50 £7.88 £5.25
2 Fetherston Inner 30 £147.00 £134.75 £122.50 £110.25 £98.00 £85.75
£73.50 £61.25 £49.00 £36.75 £24.50
2 Fetherston Outer 30 £168.00 £154.01 £139.99 £126.00 £112.01 £97.99
£84.00 £70.01 £55.99 £42.00 £28.01
2 Grange Deep 30 £147.00 £134.75 £122.50 £110.25 £98.00 £85.75 £73.50
£61.25 £49.00 £36.75 £24.50
2 Grange Shallow 30 £124.00 £113.67 £103.33 £93.00 £82.67 £72.33
£62.00 £51.67 £41.33 £31.00 £20.67
2 Mast Rack 30 £21.00 £19.25 £17.50 £15.75 £14.00 £12.25 £10.50 £8.75
£7.00 £5.25 £3.50
2 Old Pontoon 30 £147.00 £134.75 £122.50 £110.25 £98.00 £85.75 £73.50
£61.25 £49.00 £36.75 £24.50
2 Outboard Shed 30 £26.50 £24.29 £22.08 £19.88 £17.67 £15.46 £13.25
£11.04 £8.83 £6.63 £4.42
2 Rib Rack 30 £26.50 £24.29 £22.08 £19.88 £17.67 £15.46 £13.25 £11.04
£8.83 £6.63 £4.42
2 Sail Locker 30 £26.50 £24.29 £22.08 £19.88 £17.67 £15.46 £13.25
£11.04 £8.83 £6.63 £4.42
which is rather similar to Sara choosing the fiscal month & year
Phil
"Bob Quintal" <rquintal at (no spam) sPAmpatico.ca> wrote in message
news:Xns9CB0ADF89E98FBQuintal at (no spam) 69.16.185.252...
Quote: sara <saraqpost at (no spam) yahoo.com> wrote in
news:99f10e56-13b5-4194-b131-a68e3ec68dde at (no spam) m11g2000vbl.googlegroups.co
m:
On Oct 26, 7:00 am, sara <saraqp... at (no spam) yahoo.com> wrote:
On Oct 26, 12:44 am, Marshall Barton <marshbar... at (no spam) wowway.com
wrote:
sara wrote:
[]
I tried this and I'm still not getting the "right" order; I
think it's when I switch years.
[]
I expect to see 12, 11, 10, 9 8, 7, 6, 5, 4, 3, 2, 1 (I put 12
- instead of 13 - I have to work that one out myself for a
bit to figure out which number is right!)
But I'm seeing: 9, 8, 7, 6, 5, 4, 3,2, 12, 11, 10,1
Try it without using the Format function. Format always
results in a text string, which sort the way you are seeing.
--
Marsh
Thank you, Marsh. This does give me the numbers in the proper
sequence, but I don't know which month the numbers represent! I
don't know how to get that. I've tried tackingthe FiscalYear and
Month at the end of the above (without the format), but it
doesn't . Then it occurred to me to use the "DateSerial" that Bob
formulated for me - use that as the column heading and I think
that may work!
At least gives me the next step. I have a date - the first of
the month. I just have to figure out how to turn that into YYMM
(Fiscal yr and Mo) in the report....which I should be able to do
with a format statement (I'm hoping) OR do it in the final query
I write for the report.
Do you think that will work? I will try this approach later this
morning.
Many thanks - I'm getting there!
sara- Hide quoted text -
- Show quoted text -
I've tried all I can think of and I'm nowhere. I need the user to
enter FY and Fiscal Month (each chosen from combo boxes on the
form) and show the prior 12 months' data, with the proper
heading, on the report. Lost!
Thanks
Sara
You do not want to use e.g. 2009-10 as a column header in the query
feeding the report, because next month you will have a new column to
add and an old column to delete and the other columns will all need
to be moved. .
The query takes the data from the form to generate numbers from 1 to
12. (or 0 to 11)... That same form data can be used in the report to
calculate the headers for the report. The textboxes get their data
from the fields named 1 to 12.
--
Bob Quintal
PA is y I've altered my email address. |
|
|
| Back to top |
|
|
|
| Marshall Barton... |
Posted: Tue Oct 27, 2009 2:42 am |
|
|
|
Guest
|
sara wrote:
Quote: On Oct 26, 12:35 pm, Marshall Barton <marshbar... at (no spam) wowway.com> wrote:
sara wrote:
Thank you, Marsh. This does give me the numbers in the proper
sequence, but I don't know which month the numbers represent! I don't
know how to get that. I've tried tackingthe FiscalYear and Month at
the end of the above (without the format), but it doesn't .
Then it occurred to me to use the "DateSerial" that Bob formulated for
me - use that as the column heading and I think that may work!
At least gives me the next step. I have a date - the first of the
month. I just have to figure out how to turn that into YYMM (Fiscal
yr and Mo) in the report....which I should be able to do with a format
statement (I'm hoping) OR do it in the final query I write for the
report.
I think the heading text boxes would each use an expression
something like:
=DateSerial(Forms.frmChooseAccount.cboFiscalYear,
Forms.frmChooseAccount.cboFiscalMonth - 12, 1)
=DateSerial(Forms.frmChooseAccount.cboFiscalYear,
Forms.frmChooseAccount.cboFiscalMonth - 11, 1)
. . .
=DateSerial(Forms.frmChooseAccount.cboFiscalYear,
Forms.frmChooseAccount.cboFiscalMonth - 1, 1)
Set the text box's Format property to display the date the
way you want to see it.
--
Marsh
I hope I didn't speak too soon,....While I am able to get the data on
a report, I don't see how to get from the Crosstab query into a Temp
Table - dynamically. I know how to put the code for a query into VBA
(I struggle, but I usually manage to get it done!), but I don't even
see how this will help me here.
I have the crosstab which creates columns with the names "7/1/2009"
"8/1/2009". I need to get that into a temp table (or other query) but
the field names will be different every time.
Does this make sense? Once again - I fell I'm really close, but just
not there. Like I have step 1 and 3, but can't get step 2.
Why would you want to put that into a table? You should be
able to run the report's crosstab query whenever you want to
see the data.
I can't see why you would need to, but if you really feel
it's necessay to put that data in another table, can you use
the crosstab query as the source of a make table or append
query?
--
Marsh |
|
|
| Back to top |
|
|
|
| Salad... |
Posted: Tue Oct 27, 2009 4:09 am |
|
|
|
Guest
|
sara wrote:
Quote: On Oct 26, 12:35 pm, Marshall Barton <marshbar... at (no spam) wowway.com> wrote:
sara wrote:
Thank you, Marsh. This does give me the numbers in the proper
sequence, but I don't know which month the numbers represent! I don't
know how to get that. I've tried tackingthe FiscalYear and Month at
the end of the above (without the format), but it doesn't .
Then it occurred to me to use the "DateSerial" that Bob formulated for
me - use that as the column heading and I think that may work!
At least gives me the next step. I have a date - the first of the
month. I just have to figure out how to turn that into YYMM (Fiscal
yr and Mo) in the report....which I should be able to do with a format
statement (I'm hoping) OR do it in the final query I write for the
report.
I think the heading text boxes would each use an expression
something like:
=DateSerial(Forms.frmChooseAccount.cboFiscalYear,
Forms.frmChooseAccount.cboFiscalMonth - 12, 1)
=DateSerial(Forms.frmChooseAccount.cboFiscalYear,
Forms.frmChooseAccount.cboFiscalMonth - 11, 1)
. . .
=DateSerial(Forms.frmChooseAccount.cboFiscalYear,
Forms.frmChooseAccount.cboFiscalMonth - 1, 1)
Set the text box's Format property to display the date the
way you want to see it.
--
Marsh
I hope I didn't speak too soon,....While I am able to get the data on
a report, I don't see how to get from the Crosstab query into a Temp
Table - dynamically. I know how to put the code for a query into VBA
(I struggle, but I usually manage to get it done!), but I don't even
see how this will help me here.
I have the crosstab which creates columns with the names "7/1/2009"
"8/1/2009". I need to get that into a temp table (or other query) but
the field names will be different every time.
Does this make sense? Once again - I fell I'm really close, but just
not there. Like I have step 1 and 3, but can't get step 2.
Sorry if there's confusion here.
sara
I haven't been following this thread much but I did see cross tab and
headings. This is an article that may have some benefit for you.
http://www.fmsinc.com/tpapers/access/Reports/monthly/index.html |
|
|
| Back to top |
|
|
|
| Marshall Barton... |
Posted: Tue Oct 27, 2009 5:15 am |
|
|
|
Guest
|
sara wrote:
Quote: Well I reviewed the article from Salad and see you CAN use a crosstab
as a data source for a report,which I did get to work. But the field
names (here we go again!) in the report do not match the field names
in the query, so when the input date changes, and I go to run the
report, I get "Microsoft Jet database engine does not recognize " as a
valid fieldname or expression". I figured this out to be the field
name on the report is not in the query.
SO, the question is how can I have a dynamic field name as the column
heading of the crosstab query? Maybe get it to be a number somehow,
which would always be there and then still be able to use the
DateSerial formula for the headers? I do have to make sure the data in
each column is correct....
But, but, but, using the crosstab query as the report's
record source is what all of us have been talking about all
the way through this thread. Just use the calculated fields
as Bob said to generate the month numbers (1,2,...,12) in
the query. Use the same calculation in the Pivot clause
along with IN (as Chuck said) to sort them and make sure
they are all there even if there is a month with no data.
Then text box expressions I suggested for column headers in
the report should finish this off, no extraneous table
needed.
--
Marsh |
|
|
| Back to top |
|
|
|
| sara... |
Posted: Tue Oct 27, 2009 12:29 pm |
|
|
|
Guest
|
On Oct 26, 8:09 pm, Salad <o... at (no spam) vinegar.com> wrote:
Quote: sara wrote:
On Oct 26, 12:35 pm, Marshall Barton <marshbar... at (no spam) wowway.com> wrote:
sara wrote:
Thank you, Marsh. This does give me the numbers in the proper
sequence, but I don't know which month the numbers represent! I don't
know how to get that. I've tried tackingthe FiscalYear and Month at
the end of the above (without the format), but it doesn't .
Then it occurred to me to use the "DateSerial" that Bob formulated for
me - use that as the column heading and I think that may work!
At least gives me the next step. I have a date - the first of the
month. I just have to figure out how to turn that into YYMM (Fiscal
yr and Mo) in the report....which I should be able to do with a format
statement (I'm hoping) OR do it in the final query I write for the
report.
I think the heading text boxes would each use an expression
something like:
=DateSerial(Forms.frmChooseAccount.cboFiscalYear,
Forms.frmChooseAccount.cboFiscalMonth - 12, 1)
=DateSerial(Forms.frmChooseAccount.cboFiscalYear,
Forms.frmChooseAccount.cboFiscalMonth - 11, 1)
. . .
=DateSerial(Forms.frmChooseAccount.cboFiscalYear,
Forms.frmChooseAccount.cboFiscalMonth - 1, 1)
Set the text box's Format property to display the date the
way you want to see it.
--
Marsh
I hope I didn't speak too soon,....While I am able to get the data on
a report, I don't see how to get from the Crosstab query into a Temp
Table - dynamically. I know how to put the code for a query into VBA
(I struggle, but I usually manage to get it done!), but I don't even
see how this will help me here.
I have the crosstab which creates columns with the names "7/1/2009"
"8/1/2009". I need to get that into a temp table (or other query) but
the field names will be different every time.
Does this make sense? Once again - I fell I'm really close, but just
not there. Like I have step 1 and 3, but can't get step 2.
Sorry if there's confusion here.
sara
I haven't been following this thread much but I did see cross tab and
headings. This is an article that may have some benefit for you.http://www.fmsinc.com/tpapers/access/Reports/monthly/index.html- Hide quoted text -
- Show quoted text -
This was very helpful - thank you. I'm going to look around this site
(in addition to my Ken Getz book!) for other questions.
Sara |
|
|
| Back to top |
|
|
|
| sara... |
Posted: Wed Oct 28, 2009 12:00 am |
|
|
|
Guest
|
On Oct 27, 7:02 pm, Bob Quintal <rquin... at (no spam) sPAmpatico.ca> wrote:
Quote: sara <saraqp... at (no spam) yahoo.com> wrote innews:af350a2b-c8ab-48dc-b589-1137b5462891 at (no spam) o10g2000yqa.googlegroups.co
m:
On Oct 26, 5:06 pm, Bob Quintal <rquin... at (no spam) sPAmpatico.ca> wrote:
sara <saraqp... at (no spam) yahoo.com> wrote
innews:99f10e56-13b5-4194-b131-a68e3ec68
d... at (no spam) m11g2000vbl.googlegroups.co
m:
On Oct 26, 7:00 am, sara <saraqp... at (no spam) yahoo.com> wrote:
On Oct 26, 12:44 am, Marshall Barton <marshbar... at (no spam) wowway.com
wrote:
sara wrote:
[]
I tried this and I'm still not getting the "right" order; I
think it's when I switch years.
[]
I expect to see 12, 11, 10, 9 8, 7, 6, 5, 4, 3, 2, 1 (I put
12 - instead of 13 - I have to work that one out myself
for a bit to figure out which number is right!)
But I'm seeing: 9, 8, 7, 6, 5, 4, 3,2, 12, 11, 10,1
Try it without using the Format function. Format always
results in a text string, which sort the way you are seeing.
--
Marsh
Thank you, Marsh. This does give me the numbers in the proper
sequence, but I don't know which month the numbers represent!
I don't know how to get that. I've tried tackingthe
FiscalYear and Month at the end of the above (without the
format), but it doesn't . Then it occurred to me to use the
"DateSerial" that Bob formulated for me - use that as the
column heading and I think that may work!
At least gives me the next step. I have a date - the first
of the month. I just have to figure out how to turn that into
YYMM (Fiscal yr and Mo) in the report....which I should be
able to do with a format statement (I'm hoping) OR do it in
the final query I write for the report.
Do you think that will work? I will try this approach later
this morning.
Many thanks - I'm getting there!
sara- Hide quoted text -
- Show quoted text -
I've tried all I can think of and I'm nowhere. I need the user
to enter FY and Fiscal Month (each chosen from combo boxes on
the form) and show the prior 12 months' data, with the proper
heading, on the report. Lost!
Thanks
Sara
You do not want to use e.g. 2009-10 as a column header in the
query feeding the report, because next month you will have a new
column to add and an old column to delete and the other columns
will all need to be moved. .
The query takes the data from the form to generate numbers from 1
to 12. (or 0 to 11)... That same form data can be used in the
report to calculate the headers for the report. The textboxes get
their data from the fields named 1 to 12.
--
Bob Quintal
PA is y I've altered my email address.- Hide quoted text -
- Show quoted text -
This is what I was trying to do - just posted in my last message
(at least that was my intent). I put your formula back in my
crosstab and put the headings in order: 12, 10, 9, ....
Now, how do I konw the column headings that I created using what
Marshall suggested:
=DateSerial([Forms].[frmReports].[cboFiscalYear],
[Forms].[frmReports].[cboFiscalMonth]-12,1) (-11, -10, etc)
"match" the data (col 12 as you suggested has to be the date
associated with the formula here)???
I actually got this working...in that I see data in all the
columns, etc. (I had to change your formula to start with 12- not
13-(12-
DateDiff("m",DateSerial([FiscalYr],[FiscalMonth],1),DateSerial([For
ms].
[frmReports].[cboFiscalYear],[Forms].[frmReports].[cboFiscalMonth],
1)))). But how do I know the column "1" is really the one I have
in the formula (above)? I think it should be, based on it's using
the same fields, but I absolutely want to be certain.
I *might* actually have gotten this (with all your help!)
The only way I can think of is to copy the query, turn off the
crosstab option in the copy, and show both the number 1-12 and the
datevalue side by side. If the number and the datevalue agree, then
you will know that the calculations are correct and can trust the
crosstab.
--
Bob Quintal
PA is y I've altered my email address.- Hide quoted text -
- Show quoted text -
That's sort of what I did - I also checked the individual columns....I
can write a report with just one month to check it.
Anyway, thanks to your help - and others here - I did it! The
report does what I want and tomorrow I'm going to show it to the
accountant and see what he thinks.
Once again, my heartfelt thanks. I'm alone here - and no one in the
office up North knows Access - so I am dependent on the help in this
group. I've learned a lot with this problem/question.
Sara |
|
|
| Back to top |
|
|
|
| sara... |
Posted: Wed Oct 28, 2009 12:03 am |
|
|
|
Guest
|
On Oct 27, 12:19 am, Marshall Barton <marshbar... at (no spam) wowway.com> wrote:
Quote: sara wrote:
Well I reviewed the article from Salad and see you CAN use a crosstab
as a data source for a report,which I did get to work. But the field
names (here we go again!) in the report do not match the field names
in the query, so when the input date changes, and I go to run the
report, I get "Microsoft Jet database engine does not recognize " as a
valid fieldname or expression". I figured this out to be the field
name on the report is not in the query.
SO, the question is how can I have a dynamic field name as the column
heading of the crosstab query? Maybe get it to be a number somehow,
which would always be there and then still be able to use the
DateSerial formula for the headers? I do have to make sure the data in
each column is correct....
But, but, but, using the crosstab query as the report's
record source is what all of us have been talking about all
the way through this thread. Just use the calculated fields
as Bob said to generate the month numbers (1,2,...,12) in
the query. Use the same calculation in the Pivot clause
along with IN (as Chuck said) to sort them and make sure
they are all there even if there is a month with no data.
Then text box expressions I suggested for column headers in
the report should finish this off, no extraneous table
needed.
--
Marsh
I see that - I was getting an error and (mistakenly) assumed it was
because I was using the crosstab as the data source for the report.
Being stubborn and persistent has its downside too - I don't always
look at the whole problem - just assume an answer, and it's not always
right. And I got the report that I need, and NO make table!
As I've said, I am very grateful for the help. I've got it now - and
I learned a bunch in the process!
With sincere appreciation -
Sara |
|
|
| Back to top |
|
|
|
| Bob Quintal... |
Posted: Wed Oct 28, 2009 3:02 am |
|
|
|
Guest
|
sara <saraqpost at (no spam) yahoo.com> wrote in
news:af350a2b-c8ab-48dc-b589-1137b5462891 at (no spam) o10g2000yqa.googlegroups.co
m:
Quote: On Oct 26, 5:06 pm, Bob Quintal <rquin... at (no spam) sPAmpatico.ca> wrote:
sara <saraqp... at (no spam) yahoo.com> wrote
innews:99f10e56-13b5-4194-b131-a68e3ec68
dde at (no spam) m11g2000vbl.googlegroups.co
m:
On Oct 26, 7:00 am, sara <saraqp... at (no spam) yahoo.com> wrote:
On Oct 26, 12:44 am, Marshall Barton <marshbar... at (no spam) wowway.com
wrote:
sara wrote:
[]
I tried this and I'm still not getting the "right" order; I
think it's when I switch years.
[]
I expect to see 12, 11, 10, 9 8, 7, 6, 5, 4, 3, 2, 1 (I put
12 - instead of 13 - I have to work that one out myself
for a bit to figure out which number is right!)
But I'm seeing: 9, 8, 7, 6, 5, 4, 3,2, 12, 11, 10,1
Try it without using the Format function. Format always
results in a text string, which sort the way you are seeing.
--
Marsh
Thank you, Marsh. This does give me the numbers in the proper
sequence, but I don't know which month the numbers represent!
I don't know how to get that. I've tried tackingthe
FiscalYear and Month at the end of the above (without the
format), but it doesn't . Then it occurred to me to use the
"DateSerial" that Bob formulated for me - use that as the
column heading and I think that may work!
At least gives me the next step. I have a date - the first
of the month. I just have to figure out how to turn that into
YYMM (Fiscal yr and Mo) in the report....which I should be
able to do with a format statement (I'm hoping) OR do it in
the final query I write for the report.
Do you think that will work? I will try this approach later
this morning.
Many thanks - I'm getting there!
sara- Hide quoted text -
- Show quoted text -
I've tried all I can think of and I'm nowhere. I need the user
to enter FY and Fiscal Month (each chosen from combo boxes on
the form) and show the prior 12 months' data, with the proper
heading, on the report. Lost!
Thanks
Sara
You do not want to use e.g. 2009-10 as a column header in the
query feeding the report, because next month you will have a new
column to add and an old column to delete and the other columns
will all need to be moved. .
The query takes the data from the form to generate numbers from 1
to 12. (or 0 to 11)... That same form data can be used in the
report to calculate the headers for the report. The textboxes get
their data from the fields named 1 to 12.
--
Bob Quintal
PA is y I've altered my email address.- Hide quoted text -
- Show quoted text -
This is what I was trying to do - just posted in my last message
(at least that was my intent). I put your formula back in my
crosstab and put the headings in order: 12, 10, 9, ....
Now, how do I konw the column headings that I created using what
Marshall suggested:
=DateSerial([Forms].[frmReports].[cboFiscalYear],
[Forms].[frmReports].[cboFiscalMonth]-12,1) (-11, -10, etc)
"match" the data (col 12 as you suggested has to be the date
associated with the formula here)???
I actually got this working...in that I see data in all the
columns, etc. (I had to change your formula to start with 12- not
13-(12-
DateDiff("m",DateSerial([FiscalYr],[FiscalMonth],1),DateSerial([For
ms].
[frmReports].[cboFiscalYear],[Forms].[frmReports].[cboFiscalMonth],
1)))). But how do I know the column "1" is really the one I have
in the formula (above)? I think it should be, based on it's using
the same fields, but I absolutely want to be certain.
I *might* actually have gotten this (with all your help!)
The only way I can think of is to copy the query, turn off the
crosstab option in the copy, and show both the number 1-12 and the
datevalue side by side. If the number and the datevalue agree, then
you will know that the calculations are correct and can trust the
crosstab.
--
Bob Quintal
PA is y I've altered my email address. |
|
|
| Back to top |
|
|
|
|
|
All times are GMT
The time now is Sun Nov 22, 2009 2:05 am
|
|