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?
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?