View Full Version : Changing the subform at run-time


PedroSantos
02-11-2002, 12:53 PM
Hy.
I'm a newbie to MS Access, and I would like to know how can I change a form's subform dynamicly, at run-time.
For example, the main form is "Persons". If the current record or person is male, I want the subform to be "MyCars" with all cars' properties. If the person is female, I want the subform to automaticly change to "MyDolls", with all the properties for the dolls.
Can I do this? How? Please, be objective in your response, because as I said, I'm a newbie at access... unfortunately, I'm needing this for school...
By the way, could you please tell me some good sites about access?
Thanks you.

Jack Cowley
02-11-2002, 01:58 PM
In the forms On Current event code like this should work:

If Me![GenderField] = "Male" Then
Me.SubformName.SourceObject = "AQuery"
ElseIf Me![GenderField = "Female" Then
Me.SubformName.SourceObject = "TheOtherQuery"
End if

Be sure and change the field names to those you actually have.