Populating fields with defaults from another table

  • Thread starter Thread starter Hera
  • Start date Start date
H

Hera

(Brand new to designing a database.)

I'm working on a new db for our school. I have one table
built with family ID data and am working on a table for
student data. There is a one-to-many primary key (FID) in
the family table relating to their students' data. The
primary key (SID) in the student table is auto-numbered.

I'd like to avoid redundant keystroking by offering up
some of the family data in the form for entering student
data. In the student table I need a student's surname and
the family surname, which may or may not be the same.
Since it's the same in the majority of records, I'd like
to pull it into the form when I tie the student to the
family ID, but not restrict editing for those blended
family situations. I think I need to bind the surname here
but it's either not editable or I can't get the list to
appear.

Thanks,
Hera
 
Hi, Hera. If you're using bound forms, the "student surname" field will
need to be bound to the surname field from the student record. I'm assuming
that the first step in the form to enter a new student is to pick the family
with which this student is associated. So, if you have a combo box
cboFamilyName for that, and a text box txtStudentSurname to be populated,
you would put code like this in the cboFamilyName_AfterUpdate event:

If Not IsNull(cboFamilyName.Value) And IsNull(txtStudentSurname.Value) Then
txtStudentSurname.Value = cboFamilyName.Value
End If

The effect of this code: after the Family Name is updated, if the Student
Surname is blank, it will automatically fill in with the Family Name, which
you can then edit. If the Student Surname is not blank, updating the Family
Name will have no effect.

HTH

Amanda
 
Back
Top