Pauline B. said:
Hope someone can help me with this. I work for a community college where
we
generate a building schedule from a list of active classes in a table
called
Active Class Schedule. My co-worker currently does this manually by
exporting
that table to Excel and inserting the class in a spreadsheet for the
number
of times the class meets. Some of our classes may only meet on a certain
day
and others may meet on multiple days, such as MTW.
The fields that are used are as follows:
StartDate
EndDate
Days (which has info such as MTWRFS)
Is there a way to create a query to generate multiple line items for a
class, showing the date that the class is meeting and use the Make Table
Query to generate the Building Schedule? I'm not sure how to format my
calculated field with DateDiff (if that is the right one). I apologize if
there is a message for this already. Please direct me to it if there is.
Any
help would be appreciated.
Hi Pauline,
PMFBI
another method would involve a calendar table
(say "tblCal") where you use Excel to "autocomplete"
a column of dates by "dragging down" after completing
the first few dates, stopping the drag "way in the future,"
then import into Access table.
make sure your new table's field (say "CalDate") is
type Date/Time
then add 1 more (text) field to "tblCal" of length 1
(say "Dy")
then run update query
UPDATE tblCal SET tblCal.Dy =
Choose(Weekday([CalDate]),"X","M","T","W","R","F","S");
used "X" for Sunday, but you may want to change to ?...
verify your values are correct for "Dy"
just as a test i created example data
ID Class StartDate EndDate Days
1 mwf 9/1/2008 9/26/2008 MWF
2 tr 9/2/2008 9/18/2008 TR
3 mtwrf 9/1/2008 9/26/2008 MTWRF
then ran query
SELECT
ACS.Class,
ACS.StartDate,
ACS.EndDate,
ACS.Days,
C.CalDate AS ClassDate,
C.Dy
FROM
[Active Class Schedule] AS ACS, tblCal AS C
WHERE
(C.CalDate
Between
ACS.StartDate
AND
ACS.EndDate)
AND
(InStr(ACS.Days, C.Dy) > 0)
ORDER BY
ACS.Class,
C.CalDate;
and got enumeration like i *think* you wanted:
Class StartDate EndDate Days ClassDate Dy
mtwrf 9/1/2008 9/26/2008 MTWRF 9/1/2008 M
mtwrf 9/1/2008 9/26/2008 MTWRF 9/2/2008 T
mtwrf 9/1/2008 9/26/2008 MTWRF 9/3/2008 W
mtwrf 9/1/2008 9/26/2008 MTWRF 9/4/2008 R
mtwrf 9/1/2008 9/26/2008 MTWRF 9/5/2008 F
mtwrf 9/1/2008 9/26/2008 MTWRF 9/8/2008 M
mtwrf 9/1/2008 9/26/2008 MTWRF 9/9/2008 T
mtwrf 9/1/2008 9/26/2008 MTWRF 9/10/2008 W
mtwrf 9/1/2008 9/26/2008 MTWRF 9/11/2008 R
mtwrf 9/1/2008 9/26/2008 MTWRF 9/12/2008 F
mtwrf 9/1/2008 9/26/2008 MTWRF 9/15/2008 M
mtwrf 9/1/2008 9/26/2008 MTWRF 9/16/2008 T
mtwrf 9/1/2008 9/26/2008 MTWRF 9/17/2008 W
mtwrf 9/1/2008 9/26/2008 MTWRF 9/18/2008 R
mtwrf 9/1/2008 9/26/2008 MTWRF 9/19/2008 F
mtwrf 9/1/2008 9/26/2008 MTWRF 9/22/2008 M
mtwrf 9/1/2008 9/26/2008 MTWRF 9/23/2008 T
mtwrf 9/1/2008 9/26/2008 MTWRF 9/24/2008 W
mtwrf 9/1/2008 9/26/2008 MTWRF 9/25/2008 R
mtwrf 9/1/2008 9/26/2008 MTWRF 9/26/2008 F
mwf 9/1/2008 9/26/2008 MWF 9/1/2008 M
mwf 9/1/2008 9/26/2008 MWF 9/3/2008 W
mwf 9/1/2008 9/26/2008 MWF 9/5/2008 F
mwf 9/1/2008 9/26/2008 MWF 9/8/2008 M
mwf 9/1/2008 9/26/2008 MWF 9/10/2008 W
mwf 9/1/2008 9/26/2008 MWF 9/12/2008 F
mwf 9/1/2008 9/26/2008 MWF 9/15/2008 M
mwf 9/1/2008 9/26/2008 MWF 9/17/2008 W
mwf 9/1/2008 9/26/2008 MWF 9/19/2008 F
mwf 9/1/2008 9/26/2008 MWF 9/22/2008 M
mwf 9/1/2008 9/26/2008 MWF 9/24/2008 W
mwf 9/1/2008 9/26/2008 MWF 9/26/2008 F
tr 9/2/2008 9/18/2008 TR 9/2/2008 T
tr 9/2/2008 9/18/2008 TR 9/4/2008 R
tr 9/2/2008 9/18/2008 TR 9/9/2008 T
tr 9/2/2008 9/18/2008 TR 9/11/2008 R
tr 9/2/2008 9/18/2008 TR 9/16/2008 T
tr 9/2/2008 9/18/2008 TR 9/18/2008 R
of course you may want to adjust query for specific
fields you want from the 2 tables...plus change to
append or make-table...
sorry if explanation is brief but 1-hand typing at moment...
good luck,
gary