D
DIH
First off, let me say that the database I'm dealing with was created a
long while ago by someone who did not really follow proper database
design and now has been trust upon me. Table names have spaces (not a
huge deal - but still), the other large error is the use of the key word
"DATE" as a table field. With that said, here is a quick recap and my
question:
I previously posted that my company is now using a 4 week, 4 week, 5
week fiscal calendar. This will make a month (say October) not start on
the 1st and end on the 31st.
What I need to do is fix all the month to date reports/charts. I have a
form called "frmDailyProdReport" that has a calendar control in it that
the user selects a date from and the report will show the month to that
date figures (e.g. the user clicks 10/23/08 and the report shows data
from 10/1/08 thru 10/23/08).This is all pretty normal stuff for me.
Unfortunately now, the start of the month is no longer on the 1st. I
have created a table called, "tblFiscal2009LookUp" that holds the fiscal
year info.Its fields are: DayOfYear (10/1/08, 10/2/08 etc), WeekOfYear
(1, 2, 3 etc), MonthOfYear (1, 2, 3 etc), MonthName (Oct, Nov, Dec etc),
QuarterOfYear (1,2,3,4) and FiscalYear (2009).
The main table in the db is called, "DAILY SHIFT". This table contains
the date, how many units produced, downtime minutes, code number and
many other metrics.
I joined tblFiscal2009LookUp to "Daily Shift" with the date field. Here
is the sql:
SELECT [DAILY SHIFT].DATE, [DAILY SHIFT].LINE, [DAILY SHIFT].CODE,
[DAILY SHIFT].THEORETICAL, [DAILY SHIFT].ACTUAL, [DAILY SHIFT].DT,
tblFiscal2009LookUp.DayOfYear, tblFiscal2009LookUp.WeekOfYear,
tblFiscal2009LookUp.MonthOfYear, tblFiscal2009LookUp.MonthName,
tblFiscal2009LookUp.QuarterOfYear, tblFiscal2009LookUp.FiscalYear
FROM [DAILY SHIFT] INNER JOIN tblFiscal2009LookUp ON [DAILY SHIFT].DATE
= tblFiscal2009LookUp.DayOfYear;
The result of this query simply shows all the records in the DAILY SHIFT
table with the addition of the fiscal dates data from the
tblFiscal2009LookUp table.
Again, the control on the form is called,
[forms]![frmDailyProdReport]![cboStartDate].
So... What I need is a query (or at least the WHERE or HAVING sql
statement)that when the user selects a date from the calendar control,
the results will be only the records in that particular fiscal month to
date. I can then do the summing stuff.
Thanks to John W. Vinson [MVP] for getting me started (from my previous
post titled "Fiscal Year" - posted 11/17/08) on what I believe is the
right track by using a calendar translation table.
Thanks again in advance for any help,
Dave
long while ago by someone who did not really follow proper database
design and now has been trust upon me. Table names have spaces (not a
huge deal - but still), the other large error is the use of the key word
"DATE" as a table field. With that said, here is a quick recap and my
question:
I previously posted that my company is now using a 4 week, 4 week, 5
week fiscal calendar. This will make a month (say October) not start on
the 1st and end on the 31st.
What I need to do is fix all the month to date reports/charts. I have a
form called "frmDailyProdReport" that has a calendar control in it that
the user selects a date from and the report will show the month to that
date figures (e.g. the user clicks 10/23/08 and the report shows data
from 10/1/08 thru 10/23/08).This is all pretty normal stuff for me.
Unfortunately now, the start of the month is no longer on the 1st. I
have created a table called, "tblFiscal2009LookUp" that holds the fiscal
year info.Its fields are: DayOfYear (10/1/08, 10/2/08 etc), WeekOfYear
(1, 2, 3 etc), MonthOfYear (1, 2, 3 etc), MonthName (Oct, Nov, Dec etc),
QuarterOfYear (1,2,3,4) and FiscalYear (2009).
The main table in the db is called, "DAILY SHIFT". This table contains
the date, how many units produced, downtime minutes, code number and
many other metrics.
I joined tblFiscal2009LookUp to "Daily Shift" with the date field. Here
is the sql:
SELECT [DAILY SHIFT].DATE, [DAILY SHIFT].LINE, [DAILY SHIFT].CODE,
[DAILY SHIFT].THEORETICAL, [DAILY SHIFT].ACTUAL, [DAILY SHIFT].DT,
tblFiscal2009LookUp.DayOfYear, tblFiscal2009LookUp.WeekOfYear,
tblFiscal2009LookUp.MonthOfYear, tblFiscal2009LookUp.MonthName,
tblFiscal2009LookUp.QuarterOfYear, tblFiscal2009LookUp.FiscalYear
FROM [DAILY SHIFT] INNER JOIN tblFiscal2009LookUp ON [DAILY SHIFT].DATE
= tblFiscal2009LookUp.DayOfYear;
The result of this query simply shows all the records in the DAILY SHIFT
table with the addition of the fiscal dates data from the
tblFiscal2009LookUp table.
Again, the control on the form is called,
[forms]![frmDailyProdReport]![cboStartDate].
So... What I need is a query (or at least the WHERE or HAVING sql
statement)that when the user selects a date from the calendar control,
the results will be only the records in that particular fiscal month to
date. I can then do the summing stuff.
Thanks to John W. Vinson [MVP] for getting me started (from my previous
post titled "Fiscal Year" - posted 11/17/08) on what I believe is the
right track by using a calendar translation table.
Thanks again in advance for any help,
Dave