Trouble with Subform Recordsource

smaumau

Registered User.
Local time
Today, 04:40
Joined
Feb 23, 2006
Messages
32
The following code is applied to the On Current event for a subform called SubContracts.

If Me.ContractID <> "" Then
Me.Parent.SubMeters.Form.RecordSource = "SELECT * FROM Budgets.MetersXContracts WHERE ContractID = " & Me.ContractID
Me.Parent.SubMeters.Form.ContractIDHeader = Me.ContractID
Me.Parent.SubMeters.Form.ListMeter.RowSource = strsql3 & strsql4
Me.Parent.AvailableMeters.RowSource = strsql & strsql2
Me.Parent.SubTerms.Form.RecordSource = "SELECT * FROM Budgets.ContractsXTerms WHERE ContractID = " & Me.ContractID
Me.Parent.SubTerms.Form.ContractIDHeader = Me.ContractID
End If

The SubMeters form and SubTerms forms referred two are both subforms of a mainform.

For some reason that I can't determine the first four lines of this statement work properly when the main form is opened and the last two do not. I receive the error: Run-time error '2455' You entered an expression that has an invalid reference to the property Form/Report. Once I end the error all lines of the code work properly. I can't figure out why the last two lines don't work when the form is originally opened. Any thoughts?
 
A subform that's present on the parentform at design time opens before the parentform. What I commonly do is load the subforms programmatically by setting the sourceobject property in the Form_Open() handler of the parent.
 

Users who are viewing this thread

Back
Top Bottom