Sidney Lynn
New member
- Local time
- Today, 16:49
- Joined
- Jun 4, 2003
- Messages
- 6
This is a great website, folks! Here is my situation:
Records are being downloaded from a mainframe into an Access table. Unfortunately, the field names are AugCurrSales, AugPriorSales, etc. for current year and prior year sales. I started creating reports, but already have SOOO many queries, reports, and subreports.
To get the data into a more “normal” structure, I did the following: I created 12 queries to extract the data for each month. For example, qryAugust has (among others) a Month field, Mo# field, CurrSales field, and PriorSales field. I ‘manually’ enter “August” in the month field and “8” in the Mo# field for each record.
Then I created a Union Query that merges the 12 month queries together. So now my Union Query has the same data in it as the original table, but instead of one record and multiple fields for months of Sales and PriorSales, in this Union Query each Location now has 12 records - one for each month. (PS: I can’t put an actual date in the Date field in my 12 month queries because as each new year occurs the same fields are used … otherwise I could use ‘Between’ parameter prompts).
Here’s the problem. Management wants to be able to choose a month from a form and click ‘print’ and 10 different reports will print for that month. However, most reports show (among other values and in different groupings) CurrSales and PriorSales for the month, AND Year-to-Date values! I have successfully created a Dialog Form that lets the user choose from a list of months and then send that selection to the query that the report is based upon and one report prints the month’s values. But I need help figuring out how to calculate the YTD values, how to get them on the same report as the monthly values, and how to print all 10 reports at the same time.
The fiscal year is July 1 - June 30. I don’t know VBA but want to learn it. I’ve spent 5 days reading and looking on the Internet for answers - and have learned a lot - but I need help.
Q1: To calculate YTD values, would I create Select Case code that - depending on which month the user selected in the drop-down listbox - & have the code sum the values in the CurrSales and PriorSales fields “? I.e. If Mo#=9, then YTDCurrSales = (CurrSales where Mo#=7 + CurrSales where Mo#=8 + CurrSales where Mo#=”9”). That looked like a possibility from my research. What do you recommend?
Q2: If Q1 is accomplished with VBA code, I think from my reading I can figure out how/where to type it in, but where do I point to the code so that it will run ‘after’ the selection is made on the form and pass the month and calculated values to the 10 reports? (Another Switchboard form gives the manager the option of previewing any report for any month, so I don’t want to hard-code an event in the reports if I can help it)
Q3: To automatically print the 10 reports with one “OK” command button, it appears I just need multiple DoCmd Open Report lines. If I didn’t have the YTD challenge in Q1, I’d guess that this commands could go in a macro attached to the “OnClose” event of the form or something. I’ve not tried to print multiple reports with one command button before. Please advise in this instance.
Q4: Lastly, how do I put monthly data and YTD data in the same report? I’ve not done a Cross-Tab report before but saw some references to that. But since I’m not sure how to calculate the YTD values, I can’t make headway here. Please advise.
I hope my description above is clear. I had hoped to figure this out all by myself, but am running out of time and just lost my mind. Please help. Thanks in advance.
Records are being downloaded from a mainframe into an Access table. Unfortunately, the field names are AugCurrSales, AugPriorSales, etc. for current year and prior year sales. I started creating reports, but already have SOOO many queries, reports, and subreports.
To get the data into a more “normal” structure, I did the following: I created 12 queries to extract the data for each month. For example, qryAugust has (among others) a Month field, Mo# field, CurrSales field, and PriorSales field. I ‘manually’ enter “August” in the month field and “8” in the Mo# field for each record.
Then I created a Union Query that merges the 12 month queries together. So now my Union Query has the same data in it as the original table, but instead of one record and multiple fields for months of Sales and PriorSales, in this Union Query each Location now has 12 records - one for each month. (PS: I can’t put an actual date in the Date field in my 12 month queries because as each new year occurs the same fields are used … otherwise I could use ‘Between’ parameter prompts).
Here’s the problem. Management wants to be able to choose a month from a form and click ‘print’ and 10 different reports will print for that month. However, most reports show (among other values and in different groupings) CurrSales and PriorSales for the month, AND Year-to-Date values! I have successfully created a Dialog Form that lets the user choose from a list of months and then send that selection to the query that the report is based upon and one report prints the month’s values. But I need help figuring out how to calculate the YTD values, how to get them on the same report as the monthly values, and how to print all 10 reports at the same time.
The fiscal year is July 1 - June 30. I don’t know VBA but want to learn it. I’ve spent 5 days reading and looking on the Internet for answers - and have learned a lot - but I need help.
Q1: To calculate YTD values, would I create Select Case code that - depending on which month the user selected in the drop-down listbox - & have the code sum the values in the CurrSales and PriorSales fields “? I.e. If Mo#=9, then YTDCurrSales = (CurrSales where Mo#=7 + CurrSales where Mo#=8 + CurrSales where Mo#=”9”). That looked like a possibility from my research. What do you recommend?
Q2: If Q1 is accomplished with VBA code, I think from my reading I can figure out how/where to type it in, but where do I point to the code so that it will run ‘after’ the selection is made on the form and pass the month and calculated values to the 10 reports? (Another Switchboard form gives the manager the option of previewing any report for any month, so I don’t want to hard-code an event in the reports if I can help it)
Q3: To automatically print the 10 reports with one “OK” command button, it appears I just need multiple DoCmd Open Report lines. If I didn’t have the YTD challenge in Q1, I’d guess that this commands could go in a macro attached to the “OnClose” event of the form or something. I’ve not tried to print multiple reports with one command button before. Please advise in this instance.
Q4: Lastly, how do I put monthly data and YTD data in the same report? I’ve not done a Cross-Tab report before but saw some references to that. But since I’m not sure how to calculate the YTD values, I can’t make headway here. Please advise.
I hope my description above is clear. I had hoped to figure this out all by myself, but am running out of time and just lost my mind. Please help. Thanks in advance.
Last edited: