RE: Changing data in a field using a form

Tech-Archive recommends: Fix windows errors by optimizing your registry



You really do need two tables for this. Here is how they should be structured:
tblStudent
STUDENT_ID - AutoNumber, Primary Key
STUDENT_NAME - Text
HOURS_GIVEN - Long Integer

tblHours
HOUR_ID - AutoNumber, Primary Key
STUDENT_ID - Long Integer Links to tblStudent
DATE_COMPLETED - Date
HOURS_COMPLETED - Long Integer

Don't store the Hours remaining. It violates one of the basic rules of
database normalization - "never store a calculated value"

You will need a Form with a SubForm. The form should have a combo box to
look up the student, a text box for the student's name, a text box for the
hours given, and a text box for the hours remaining. The SubForm should have
DATE_COMPLETED and HOURS_COMPLETED and should be a data*** view.

You will calculate the hours remaining for the form using the following
function:
DSum("[HOURS_COMPLETED]", "tblHours", "[STUDENT_ID] = " & Me!cboStudent)
This calculation should go in the Current event of your form. A similar
verison should go in the After Update event of the Subform:
DSum("[HOURS_COMPLETED]", "tblHours", "[STUDENT_ID] = " &
Me.Parent!cboStudent).



"ptlm65" wrote:

>
> OK I know this may sound simple but I am a novice so please be kind.
>
> I have a table with four fields representing a student, community
> service hours assigned, community service hours served and community
> service hours remaining.
>
> the fields are:
> Name
> Hours Given
> Hours Served
> Hours Remaining
>
> What I want to do is create a form with a combo box containing the
> student's name then a text box that I can enter hours served everytime
> a particular student completes hours, and I want a command button that
> when I click it, the hours I enter into the text box to automatically
> be subtracted from the hours given entering the new total into the
> hours remaining for that student.
>
> I was thinking of adding another table to enter the date a student did
> the hours and how many they did and link it to the student's name
> (maybe fields are "Date Completed" and "hours completed" and the table
> linked to the "Name" field of the first table). I don't know if I can
> enter another text box to enter the date they did the particular hours
> and how many and add that to the table so that when I enter the hours
> served on the certain date it adds that info to the "date and hours
> served on that date" table, as well as what I want listed above,
> updating the total hours remaining.
>
> I am sure it sounds like way to much to ask but if anyone could help me
> draw up a code for a form that would accomplish this that would be a
> life saver. Thanks for any help in advance
>
>
> --
> ptlm65Posted from - http://www.officehelp.in
>
>
.


Quantcast