Refering to subform control from main

mderby

Registered User.
Local time
Today, 11:59
Joined
Apr 14, 2003
Messages
41
Hi all,

I am working on a form(A) with subform(A1) based on a Project Master(TM0001) and Project Detail(TM0002) with parent/child relationship.The primary key is Project ID. This two form is created by using the wizard.

In main Form A there is a combobox (PID) with this sql code
SELECT [TM0001].[Project ID], [TM0001].[Project Name] FROM TM0001;
so user will need to select the project ID and then another combobox(TOwner) will display the various member of this project using this sql :
SELECT DISTINCT [TM0002].[Task Owner] FROM TM0001 INNER JOIN TM0002 ON [TM0001].[Project ID]=[TM0002].[Project ID] WHERE ((([TM0001].[Project ID])=[Forms]![frmTM0001]![PID]));

After user had selected the owner , in the cbox TOwner On Click event, I want the subform the display the filtered record of those record owns by the value selected in the TOwner only.
So any help here !!!

Another question is how to we reference a control in a subform from the mainform in Code Editor. I try to assign some values using this code from the main form:
Forms![frmTM0001]![frmTM0002_Subform]![txtTaskOwner] = Me!cmbOwner where txtTaskOwner source is a field in a TM0002.

Thank beforehand

Mderby
 
Use Form_frmTM0002_Subform.txtTaskOwner = Me.cmbOwner to call an item on a subform

To update the subform use Form_frmTM0002_Subform.requery
 
On the AfterUpdate event of your combo
Me.MySubform.Requery
 
Hi guys,

thanks for the help.

I have tried those step but still cannot solve it.
I couldn't make the subform to show the selected value of a combobox.

is this code correct :
Me.frmTM0002_Subform.Form.Filter = "[Project ID] = '" & Me!cmbProjectID2 & "'"
Me.frmTM0002_Subform.Form.FilterOn = True

Thanks

Mderby
 
You can't apply a filter to a subform in this way, set the criteria of the subforms underlying query to reference the key field in the combo, just requery the subform on the after update of the combo
 
Thank Rich,

I have changed the subform to be based on a query.

Thanks a lot.

Mderby.
 

Users who are viewing this thread

Back
Top Bottom