Query choices

A

andrewt

I have students that have different schedules. I want to choose which table
the schedule is from by what day it is. I have a schedule for Monday and one
for Tues, Wed, Thurs, Friday. I want to use one query and have it decide
which day it is. Is there a way to build an expression that says: If today is
Monday use tblMonday or it today is Tue, Wed, Th or Friday use tblNormal?
 
J

John W. Vinson

I have students that have different schedules. I want to choose which table
the schedule is from by what day it is. I have a schedule for Monday and one
for Tues, Wed, Thurs, Friday. I want to use one query and have it decide
which day it is. Is there a way to build an expression that says: If today is
Monday use tblMonday or it today is Tue, Wed, Th or Friday use tblNormal?

STOP.

If you are storing data - types of schedules - in tablenames *your design is
wrong*.

You should have *ONE* table of schedules, with an additional field to indicate
whether it's a normal schedule or a Monday schedule.

If the reason you have multiple tables is that you have (say) fields for each
hour of the day or each block of time, then my advice goes double: storing
data in fieldnames is even worse than storing it in tablenames.
 
A

andrewt

I have a table for each of 3 different schedules. The heading are START; END;
MESSAGE; POSITION; CONDITION.
12:00:00 AM; 8:10:00 AM; Present 1st; 1; Before Bell. This is the data in
the first row. I used a query to determine when a student scanned in using a
bar code reader. I then use that to report a student's attendance for that
period. I am not sure what you mean by wong design? Can you elaborate? Sorry
this took so long to look at.
 
L

Larry Daugherty

John may have gone to bed by now. I'll give you my take which is
probably in line with his: If not, I'm sure he'll pick it up in the
morning.

You need *one* table for the data you are collecting. In that table
you should have fields for

student identification
login date default value format(now(), "pick a format")
login time default value format(now(), "HH:mm:ss")
(don't know why you might need start and end
times. *You* already know when the classes
start and end, This doesn't detect a student
logging in for a wrong period.

The prose you want in the table would most likely be entered by you at
a later time using a Form. Once your design is complete, always use
the forms you have designed to manage your data. Never go directly to
the tables to manage data. All of the other information relevant to
the student's logging in/scanning in is already known to you: Which
classes meet on which days and times and which students belong in
which you already know. You should have all of that other information
stored in other tables.

Tables are used to store information about entities. Tables are named
for the type of entity whose records they store. Every entity of that
type belongs in the same table. Only information about an entity
belongs in a record about that entity. Don't be afraid to use more
tables when there is good reason to do so. Never use a table to
differentiate values of an attribute of an entity. For example:
Tables named tblBlueCars and tblRedCars is a way of storing data in
table names. They are poor choices. The real entity type in this
case is "Cars". The color a car happens to be should go into a field
named something like "color" and could take on any legitimate color
value. Only one table; tblCars to store all car entities and one
field to indicate the color of the car that this record is about.
John usually gets it said with fewer words. :)

Advice: Visit www.mvps.org/access and read about the 10 Commandments
for Relational Databases. It's all true. Continue reading about the
fundamentals of designing with Relational Database Management Systems
until they make sense to you.

HTH
 
J

John W. Vinson

I have a table for each of 3 different schedules. The heading are START; END;
MESSAGE; POSITION; CONDITION.
12:00:00 AM; 8:10:00 AM; Present 1st; 1; Before Bell. This is the data in
the first row. I used a query to determine when a student scanned in using a
bar code reader. I then use that to report a student's attendance for that
period. I am not sure what you mean by wong design? Can you elaborate? Sorry
this took so long to look at.

Not much to add to Larry's suggestion, but to give an explicit example:

You don't need three tables for the three schedules (or five tables for the
five schedules when the policies change next month).

You need ONE table for all the schedules with one additional SCHEDULE field to
indicate which schedule is which.

Your query can then pick the appropriate schedule by just looking in that
field rather than needing complex VBA code to choose which table to open.
 
A

andrewt

Here is the condition statement I am using in the query to determine the
students, attendance condition:
=[Start] And <[End]

The data is:
Start- 07:58:00 AM; Present-08:03:00 AM; 08:03:01 AM Tardy; 08:33:00 AM
Truant..........This is timing for 1st period. It takes the scan time and
then compaires it, much like a lookup table and returns the condition
(present, tardy, truant)

This part has worked for years. We just now have two new schedules. I would
like the query to determine the day and then act accordingly returning the
correct condition. I do not see how just one table can accomplish this?

Thanks
 
J

John W. Vinson

Here is the condition statement I am using in the query to determine the
students, attendance condition:
=[Start] And <[End]

The data is:
Start- 07:58:00 AM; Present-08:03:00 AM; 08:03:01 AM Tardy; 08:33:00 AM
Truant..........This is timing for 1st period. It takes the scan time and
then compaires it, much like a lookup table and returns the condition
(present, tardy, truant)

This part has worked for years. We just now have two new schedules. I would
like the query to determine the day and then act accordingly returning the
correct condition. I do not see how just one table can accomplish this?

Add another criterion, on the Schedule field, to determine which schedule is
appropriate.
 
A

andrewt

John;

I guess I just don't understand. Here are the first few lines from the
tables. They are two completely different timings:

tblMorningSchedule
Start End Message Position Condition
12:00:00 AM 8:10:00 AM Present 1st 1 Before Bell
8:10:01 AM 8:20:01 AM Tardy 1st 1 In the 1st 10 minutes
8:20:02 AM 8:40:00 AM Scan Truant 1st 1 Was 10+ minutes late
8:40:01 AM 8:42:00 AM Present 2nd 2 Before Bell
8:42:01 AM 8:52:01 AM Tardy 2nd 2 In the 1st 10 minutes
-----------------

tblNormalSchedule
Start End Message Position Condition
12:00:00 AM 12:00:01 AM Present 0 0 Before Bell
12:00:02 AM 12:00:03 AM Tardy 0 0 In the 1st 30 minutes
12:00:04 AM 12:00:04 AM Scan Truant 0 0 Was 30+ minutes late
12:00:05 AM 8:12:00 AM Present 1st 1 Before Bell
8:12:01 AM 8:40:00 AM Tardy 1st 1 In the 1st 30 minutes
8:40:01 AM 8:55:00 AM Scan Truant 1st 1 Was 30+ minutes late
8:55:01 AM 8:59:30 AM Present 2nd 2 Before Bell

I just don't know how to merge them I guess? Can you give me some idea?

Thanks,

andrewt

John W. Vinson said:
Here is the condition statement I am using in the query to determine the
students, attendance condition:
=[Start] And <[End]

The data is:
Start- 07:58:00 AM; Present-08:03:00 AM; 08:03:01 AM Tardy; 08:33:00 AM
Truant..........This is timing for 1st period. It takes the scan time and
then compaires it, much like a lookup table and returns the condition
(present, tardy, truant)

This part has worked for years. We just now have two new schedules. I would
like the query to determine the day and then act accordingly returning the
correct condition. I do not see how just one table can accomplish this?

Add another criterion, on the Schedule field, to determine which schedule is
appropriate.
 
J

John W. Vinson

John;

I guess I just don't understand. Here are the first few lines from the
tables. They are two completely different timings:

tblMorningSchedule
Start End Message Position Condition
12:00:00 AM 8:10:00 AM Present 1st 1 Before Bell
8:10:01 AM 8:20:01 AM Tardy 1st 1 In the 1st 10 minutes
8:20:02 AM 8:40:00 AM Scan Truant 1st 1 Was 10+ minutes late
8:40:01 AM 8:42:00 AM Present 2nd 2 Before Bell
8:42:01 AM 8:52:01 AM Tardy 2nd 2 In the 1st 10 minutes
-----------------

tblNormalSchedule
Start End Message Position Condition
12:00:00 AM 12:00:01 AM Present 0 0 Before Bell
12:00:02 AM 12:00:03 AM Tardy 0 0 In the 1st 30 minutes
12:00:04 AM 12:00:04 AM Scan Truant 0 0 Was 30+ minutes late
12:00:05 AM 8:12:00 AM Present 1st 1 Before Bell
8:12:01 AM 8:40:00 AM Tardy 1st 1 In the 1st 30 minutes
8:40:01 AM 8:55:00 AM Scan Truant 1st 1 Was 30+ minutes late
8:55:01 AM 8:59:30 AM Present 2nd 2 Before Bell

I just don't know how to merge them I guess? Can you give me some idea?

tblSchedule
ScheduleType <values Morning, Normal, Evening, Summer, Weekend, ...>
Start
End
Message
Position
Condition

e.g.

Morning 12:00:00 AM 8:10:00 AM Present 1st 1 Before Bell
Morning 8:10:01 AM 8:20:01 AM Tardy 1st 1 In the 1st 10 minutes
Morning 8:20:02 AM 8:40:00 AM Scan Truant 1st 1 Was 10+ minutes late
Morning 8:40:01 AM 8:42:00 AM Present 2nd 2 Before Bell
Morning 8:42:01 AM 8:52:01 AM Tardy 2nd 2 In the 1st 10 minutes
Normal 12:00:00 AM 12:00:01 AM Present 0 0 Before Bell
Normal 12:00:02 AM 12:00:03 AM Tardy 0 0 In the 1st 30 minutes
Normal 12:00:04 AM 12:00:04 AM Scan Truant 0 0 Was 30+ minutes late
Normal 12:00:05 AM 8:12:00 AM Present 1st 1 Before Bell
Normal 8:12:01 AM 8:40:00 AM Tardy 1st 1 In the 1st 30 minutes
Normal 8:40:01 AM 8:55:00 AM Scan Truant 1st 1 Was 30+ minutes late
Normal 8:55:01 AM 8:59:30 AM Present 2nd 2 Before Bell


A Query (which you could even name tblMorningSchedule if you want your current
forms and reports to keep working without changes) based on tblSchedule with a
criterion of "Morning" will look, feel, work EXACTLY like your current
tblMorningSchedule.

You seem to be stuck in the mode "in order to do anything with data I have to
have a table which contains just that data exclusively". That assumption IS
WRONG.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top