Contdionally open a form based on a form and a table

L

Lee T.

I have a Class database. The Users want to add attendance
for the once a week class.

Right now I have FRM_CLASS that has the class information
and the past 4 dates that the class was held. If every
Monday and they are entering data on Thursday then the
last 4 Monday's show up. Under each is a open form button.

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.

I am not sure how to conditionally open up a form.

TIA

LT
 
A

Alick [MSFT]

Hi Lee,

I am not sure what the problem is; would you please provide a sample to
illustrate the problem? Basically I think you can add code in the form open
event to check the condition you want, once the condition does not meet the
requirements, we set the Cancel parameter to true and the form won't open.



Sincerely,

Alick Ye, MCSD
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


--------------------
| Content-Class: urn:content-classes:message
| From: "Lee T." <[email protected]>
| Sender: "Lee T." <[email protected]>
| X-Tomcat-NG: microsoft.public.access.formscoding
|
| I have a Class database. The Users want to add attendance
| for the once a week class.
|
| Right now I have FRM_CLASS that has the class information
| and the past 4 dates that the class was held. If every
| Monday and they are entering data on Thursday then the
| last 4 Monday's show up. Under each is a open form button.
|
| 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.
|
| I am not sure how to conditionally open up a form.
|
| TIA
|
| LT
|
 
D

Drew

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
 
D

Drew

My structure to you would definately keep the name out of
everwhere and only store a value relating to their name
record. Not sure if I lost you, but your comments are
180 degrees from what I was explaining. Just making sure
you understood.

Drew
 
A

Alick [MSFT]

Hi Lee,

Drew provided good suggestion; please feel free to reply to the threads if
you have any questions or concerns.



Sincerely,

Alick Ye, MCSD
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


--------------------
| Content-Class: urn:content-classes:message
| From: "Lee T." <[email protected]>
| X-Tomcat-NG: microsoft.public.access.formscoding
|
| Drew and Alick,
|
| Thanks for the responses.
|
| Alick, sorry I didn't explain it better.
|
| Drew, after the post I had a Homer Simpson moment and
| thought of the On Open of the form. D'OH! However, your
| explanation will help me a lot. I'll just have to play
| with it and see. The reason for not having the names in
| the table is that they can attend different classes AND
| this database will do other things as well and I didn't
| want to have to store the names all over the place.
|
| Thanks again and I'll let you guys know how it works
| out.
|
|
| >-----Original Message-----
| >I have a Class database. The Users want to add
| attendance
| >for the once a week class.
| >
| >Right now I have FRM_CLASS that has the class information
| >and the past 4 dates that the class was held. If every
| >Monday and they are entering data on Thursday then the
| >last 4 Monday's show up. Under each is a open form
| button.
| >
| >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.
| >
| >I am not sure how to conditionally open up a form.
| >
| >TIA
| >
| >LT
| >.
| >
|
 

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