asked on # Very complicated report - Need help

I hope I can explain the challenge. I am trying to write an Access report which has to show 52 rows of data. But first of all prior to the opening of the report is a form which asks the user to enter the current year. Example: "2012". Then going down the report vertically I need to show the week number in the first column. So I guess I need VBA code to loop 52 times but increment by weeks or 7 days each row. And then next to the week number I need a text box filled with a complicated formula. Here is my attempt at explaining the formula...

"Molds" = sum total of ([Qty] from "tblCast" divided by [Patterns_On] from "tblPartsMasters") for that week (week 1, week 2, week 3, etc.) where [Molder] from "tblCast" = "Airset Floor" and [Cust] = "ABCCompany". [Cust] is from "tblPartsMasters" joined to "tblCast" by the field [PartN] in "tblCast" and [Part_No] in "tblPartMasters". Both [PartN] and [Part_No] are text fields.

So the final report will look like:

Week Molds

1 4

2 16

3 23

4 7

etc through 52 weeks.

I suspect this question should be worth much more than 500 points but if anyone can assist I sure will appreciate it. I actually have to create 13 more text fields like the one I've explained horizontally on the report but if someone can help with this first one I think I can take it from there.

--Steve

"Molds" = sum total of ([Qty] from "tblCast" divided by [Patterns_On] from "tblPartsMasters") for that week (week 1, week 2, week 3, etc.) where [Molder] from "tblCast" = "Airset Floor" and [Cust] = "ABCCompany". [Cust] is from "tblPartsMasters" joined to "tblCast" by the field [PartN] in "tblCast" and [Part_No] in "tblPartMasters". Both [PartN] and [Part_No] are text fields.

So the final report will look like:

Week Molds

1 4

2 16

3 23

4 7

etc through 52 weeks.

I suspect this question should be worth much more than 500 points but if anyone can assist I sure will appreciate it. I actually have to create 13 more text fields like the one I've explained horizontally on the report but if someone can help with this first one I think I can take it from there.

--Steve

Microsoft Access

One additional comment: If the "Molds" answer is "0" then I need a "0" on the report.

How do you know what week each record belongs to?

This would be much easier if you could provide a copy of the database. Just remove any private information first.

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!

Walt Forbes

Peter57r: Sorry. By [Date] in "tblCast".

Will be good if you upload DB with some sample data.

You need query as report source. As I've adviced you in previous question, you need table with numbers from 1 to 52 if you like to show all weeks, independently from data for this week exists or not. In first query - calculate week number and group by this number. In other column - calculate Molds. In second query left join table witn numbers (1-52) and your query. If you like to have 0, use nz([Molds],0) for molds column.

You should also take in mind that fist and last week in year may have less then 7 days.

You need query as report source. As I've adviced you in previous question, you need table with numbers from 1 to 52 if you like to show all weeks, independently from data for this week exists or not. In first query - calculate week number and group by this number. In other column - calculate Molds. In second query left join table witn numbers (1-52) and your query. If you like to have 0, use nz([Molds],0) for molds column.

You should also take in mind that fist and last week in year may have less then 7 days.

Attached... a VERY stripped down sample of the database.

SampleDatabase.zip

Get an unlimited membership to EE for less than $4 a week.

Unlimited question asking, solutions, articles and more.

May be you need something like this. As I can see you like to have all molders in report. You can use transform query. Check Mold calculation in qryMold. May be logic is wrong.

SampleDatabase.zip

Log in or sign up to see answer

Become an EE member today7-DAY FREE TRIAL

Members can start a 7-Day Free trial then enjoy unlimited access to the platform

or

Learn why we charge membership fees

We get it - no one likes a content blocker. Take one extra minute and find out why we block content.

Not exactly the question you had in mind?

Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.

ask a question
To als315:

Using your last SampleDatabase can you help me get the total numbers in each total column also? I'm having trouble figuring out how you did this.

Also, is the form being used to determine which year's data to go after?

Thank you so much for what you've done already.

--Steve

Using your last SampleDatabase can you help me get the total numbers in each total column also? I'm having trouble figuring out how you did this.

Also, is the form being used to determine which year's data to go after?

Thank you so much for what you've done already.

--Steve

Hmm ... the last days of this December belongs to week 2013W01.

And ISO_WeekCount(Date) => 52

Year 2009 and 2015, however, had/will have 53 weeks.

And ISO_WeekCount(Date) => 52

Year 2009 and 2015, however, had/will have 53 weeks.

```
Public Function ISO_WeekCount( _
ByVal datYear As Date) _
As Byte
' Calculates number of weeks in year of datYear according to the ISO 8601:1988 standard.
'
' May be freely used and distributed.
' 2001-06-26. Gustav Brock, Cactus Data ApS, CPH
Dim bytISO_Thursday As Byte
' No special error handling.
On Error Resume Next
bytISO_Thursday = Weekday(vbThursday, vbMonday)
datYear = DateSerial(Year(datYear), 12, 31)
' Subtract one week if datYear is in week no. 1 of next year.
datYear = DateAdd("ww", Weekday(datYear, vbMonday) < bytISO_Thursday, datYear)
ISO_WeekCount = DatePart("ww", datYear, vbMonday, vbFirstFourDays)
End Function
```

/gustav
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!

James Murphy

Steve: what total value you like to use? You have Total in each line and in each column. Can you show expected result?

Form is used to calculate max week number in selected year and limit query to this number.

You should analyze Gustav's comment. May be you had to change week number calculation.

Form is used to calculate max week number in selected year and limit query to this number.

You should analyze Gustav's comment. May be you had to change week number calculation.