Change subform based on textbox text

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hi All

I have a form that lists the different classes in a school.
We only teach English or Spanish.
A textbox 'txtLanguage' shows the language of the class.
A textbox 'txtClassRef' shows the unique reference no. for the class.
'txtCourseRef' on the subform shows the same number.

I have two subforms that show the students that study Spanish or
English; sbfrmSpansih and sbfrmEnglish.

When the secretary goes through the mainform, I want the subform to show
the subform that represents the language for that class. I also want the
subform to filter only the students that have the same ClassRef as the
current mainform register.

Any ideas greatly appreciated,

Jeff
 
More Info

I've put the two language queries into one query containing all my students.

A student could study both Spanish and English so in my querry for the
subform I have to have two fields with a reference for each course.
txtEngRef
txtSpanRef

Now, in my mainform I have the textboxes 'txtLanguage' and
'txtCourseRef'. I want to filter the one subform 'sbfrmStudents' using
the txtCourseRef on the mainform and relate it to either txtEngRef or
txtSpanRef depending on the language in txtLanguage.

EG.
Mainform info: Courseref: 101
Language: Spanish
Subform info: All students studying on course with ref: 101

Really need help on this one.

Thanks,

Jeff
 
It's OK, I got it licked!

After some playing around I put code in the On Current event of the
mainform:

If Not IsNull(Me!Language) Then
Select Case Me!Language
Case "Inglês"

Forms![Turmas1]![SbAlunosdoturma].LinkChildFields = "CursoInglês"
Case "Espanhol"
Forms![Turmas1]![SbAlunosdoturma].LinkChildFields =
"CursoEspanhol"
End Select
End If

Just took some extra playing around!

Jeff
 
Back
Top