To conditionally open a form you can pass it an Open
Arguement. This may only be one value. If you want to
pass the form more than one value, you will have to use a
more complicated routine such as a Tagged Value routine
that will allow you to pass the multiple conditions and
their respective values, along with a separator which
will be used to separate the next condition.
If you only need to send one value, ie - date, then you
can pass the date in a Docmd.OpenForm .... (the last
condition of this procedure is the OpenArg) and in the On
Open event in the form that is being launch, dim a value
and set that value equal to the Open Arguements:
Dim Cond as String
Cond = Me.OpenArgs
This will pass the value as a string, so if you need to
turn it into a date or number, use the various procedures
to conduct such things like Clng(Cond) to turn the value
into a LONG. Then pass the value to whatever query or
Open Recordset code you have to retreive the data you
require.
Why are you only keeping the lsat four dates the class
was held? I do not follow your data structure and there
may be a much easier way to accomplish what you are
doing. I used to own a computer school and kept
attendance on all my students as well.
______ A little bit fo structure problem....
You wrote:
From the Open Form command button I would like to
conditionally check for the presence of that class and
that date. So if data is in the database for the 20th of
August, then display that data. Upon clicking the button
for the 27th of August and there is no data, then take all
the names for the 20th, append to the table and fill in
the date of the 27th. Then the user can check if the
person attended or not.
Ok... why would you store the names of the students in
another table? Relate the students ID (hopefully an
autonumber field or something unique) to the class in an
attendance table that has the following fields:
tbl_Student_Attnd
Attnd_ID as autonumber
Class_Period_ID as long
Student_ID as long
Student_Present as Boolean (Yes/No)
tbl_Class_Period
Class_Period_ID as autonumber
Class_ID as long
Class_Day as Date
Class_Start as Date
Class_Duration as Date/Time
tbl_Student_Class_Join
Join_ID as autonumber
Class_ID
Student_ID
tbl_Class
Class_ID as autonumber
Class_Name
Class_Instructor
etc
etc
etc
tbl_Grades
Grade_ID as autonumber
Class_ID as long
Student_ID as long
Grade_Value as text
See where I am going?????
Now, you can relate the student to a specific class which
is related to the dates the class is offered. If you put
the days that this class will offered in advance you
could also use this same structure to schedule students
and track the seat availability as students sign up for
the class.
You can now create a form that you can have a combo box
to select the class. This combo box will then fill a
List Box with the values of the dates the class is
offered, and you can put conditions of how many weeks you
wish to go back to allow them to enter data for in your
Rowsource query for the list box. Make the list box
update on the After Update event of the Class Combo Box.
You then need a third list box to fill with the students
that are scheduled for the specific class date selected.
The Class Date list box will have to code to update or
requery the Student List Box. All of the names will
appear in the List Box, so make the Student List Box a
Mulit Select. Then the people entering the data can
select all of the students that were present. You can
now have a button to save the data for the class in the
tbl_Student_Attnd table by stepping through each record
in the Students table and save the Student ID, the class
and whether the student attended or not. This is a very
simple For Each In Next statement used within a open
table .. addnew function.
Over your head yet, or are you still with me?
Otherwise..... hmmmm...
Yes ... you can open a recordset based on a specific
date, retrieve all of the data ( SELECT * FROM tablename
WHERE tablefield = condition ) and then put those on the
form, or if you wish to just put the names for the
previous date in again for the new date then use an
append query such as "APPEND tablename SET tablefield =
value, tablefield2 = value2 WHERE tablename.fieldname =
value.
I hope this helped
Drew