Referencing combobox on subform

RexesOperator

Registered User.
Local time
Today, 03:44
Joined
Jul 15, 2006
Messages
604
This is probably another easy fix (I hope).

I want to be able to clear fields on a subform using a command button on the main form. The combobox (cboTransactionID) is on a subform control(ctlTrnxsSub ). I used a different name for the control and the subform so I know which is which). The main form is frmTransactions and the subform is frmTrxnsDetailsSub.

Using the various examples (including this site -http://www.mvps.org/access/forms/frm0031.htm), and after reading Bob Larson's explantion I have the following on a command button:

Private Sub cmdClearAllFields_Click()

Me.cboCompanyID.Value = Null
Me.lbxContactID.Value = Null
Me.txtFIRSTNAME.Value = Null
Me.txtLASTNAME.Value = Null

Me.ctlTrxnsSub.Form.cboTransactionID.Value = Null

End Sub

The first four fields are on the main form and behave the way I expect them to. The last one is on the sub form and give the "Apllication-defined or object-defined error".
 
Check this link for the correct syntax for referencing forms and subforms, and there controls, from various points of reference.
 
>>>Me.ctlTrxnsSub.Form.cboTransactionID.Value = Null<<<

That looks right to me?

to test it:
I would change the "Null" to a known value, a value you know is present in the combo box and see if it works then.
 
>>>Me.ctlTrxnsSub.Form.cboTransactionID.Value = Null<<<

That looks right to me?

to test it:
I would change the "Null" to a known value, a value you know is present in the combo box and see if it works then.

Good idea - tried it and I still couldn't get it to work. After an hour of various combinations using your testing approach the following works:

Forms!NameofMainForm.NameofSubformContainer.Form.NameofControlonSubform.Value = Null (or whatever)



Sometime just having a sounding board is enough to get things going.

Thanks guys.
 

Users who are viewing this thread

Back
Top Bottom