Linking Text Boxes?

P

ptlm65

I have a table "tblStudents" with three fields
StudentID (Auto Number)
Last Name
First Name

And a second table "tblHours" with four fields
StudentID (foreign key to StudentID)
Hours Given
Date Worked
Hours Worked

I have a form with a combo box linked to "Last Name" and "First Name
of a query based on "tblStudents"and I have two text boxes.
one text box "txtLast Name" that automatically fills with the name
choose in the combo box.

My problem is the second text box "txtHours Given" When I choose a nam
from the combo box I want it to not only enter the name into the firs
text box but I want the hours given for that student to automaticall
backfill in the second text box. Can anyone help me code the secon
text box?

Also,
I want to use that form to enter the number of hours worked and have
command button that will subtract the hours worked from "Hours Given
and have the new total display in a text box for hours remaining. Ca
anyone help me with that code? Any help would be so appreciated thanks
 
J

John Welch

As far as the second part goes, (the subtraction), you could add a field to
your query that has the value:
Hours Remaining: [hours given] - [hours worked]
then your query will automatically calculate this value and you can have a
textbox on your form which is bound to this field.

About the first part of your question: it sounds like you are using the
combo boxes to find specific Student records, no? (it's not quite clear). If
that's what you're doing, then you might try getting rid of the combo boxes
on your form and just having text boxes, and using filter by form to find
records. Filter by form will change your text boxes to combo boxes so you
can find specific students. Or you could 'do it yourself' by putting unbound
combo boxes in your form's header and then set the form's filter with code
in the after update event of the combo boxes.

for more info, check Help on filtering and "filter by form" and calculated
fields in queries.

Hope this helps
-John
 
Top