Never mind - it is obvious that we do not talk the same language. Please read
my last post carefully! On Monday I have 5 consecutive classes - Oh! I give
up.
You might try something like this. I think that a parameter query could
be made to pull up a roster by just using the current date and time.
The few databases I have made do not use time, so I am unsure whether I
handled that right. Just consider this as a general idea. I omitted a
Faculty table, because I assumed this is just for one person's use.
Option Compare Database
Option Explicit
Sub CreateTables()
Dim cat
Set cat = CurrentProject.AccessConnection
With cat
.Execute _
"CREATE TABLE Students " & _
"(student_nbr INTEGER NOT NULL PRIMARY KEY, " & _
"first_name VARCHAR (25) NOT NULL, " & _
"last_name VARCHAR (25) NOT NULL);"
.Execute _
"CREATE TABLE Classes " & _
"(class_name VARCHAR (20) NOT NULL, " & _
"class_level INTEGER NOT NULL, " & _
"PRIMARY KEY (class_name, class_level));"
.Execute _
"CREATE TABLE Periods " & _
"(period_nbr INTEGER NOT NULL, " & _
"weekday_nbr INTEGER NOT NULL, " & _
"start_time DATETIME NOT NULL, " & _
"end_time DATETIME NOT NULL, " & _
"PRIMARY KEY (period_nbr, Weekday_nbr));"
.Execute _
"CREATE TABLE ClassPeriods " & _
"(class_name VARCHAR (20) NOT NULL, " & _
"class_level INTEGER NOT NULL, " & _
"CONSTRAINT fkClassPeriods_Classes " & _
"FOREIGN KEY (class_name, class_level) " & _
"REFERENCES Classes (class_name, class_level), " & _
"period_nbr INTEGER NOT NULL, " & _
"weekday_nbr INTEGER NOT NULL, " & _
"CONSTRAINT fkClassPeriods_Periods " & _
"FOREIGN KEY (period_nbr, weekday_nbr) " & _
"REFERENCES Periods (period_nbr, weekday_nbr), " & _
"PRIMARY KEY (class_name, class_level, " & _
"period_nbr, weekday_nbr));"
.Execute _
"CREATE TABLE AttendanceCodes " & _
"(attend_code CHAR (1) NOT NULL PRIMARY KEY, " & _
"attend_name VARCHAR (10) NOT NULL);"
.Execute _
"CREATE TABLE ClassPeriodAttendance " & _
"(student_nbr INTEGER NOT NULL " & _
"REFERENCES Students (student_nbr), " & _
"class_name VARCHAR (20) NOT NULL, " & _
"class_level INTEGER NOT NULL, " & _
"period_nbr INTEGER NOT NULL, " & _
"weekday_nbr INTEGER NOT NULL, " & _
"CONSTRAINT Class_Period_Attendance " & _
"FOREIGN KEY (class_name, class_level, " & _
"period_nbr, weekday_nbr) " & _
"REFERENCES ClassPeriods (class_name, class_level, " & _
"period_nbr, weekday_nbr), " & _
"Attend_code CHAR (1) NOT NULL " & _
"REFERENCES AttendanceCodes (attend_code), " & _
"calendar_date DATETIME NOT NULL DEFAULT Now(), " & _
"PRIMARY KEY (student_nbr, class_name, class_level, " & _
"period_nbr, weekday_nbr));"
End With
Set cat = Nothing
End Sub