bokaria
asked on
Access 2003 "Error Number 2455"
Hi,
When we are trying to set properties of a subform in Access we get the following error message.
"Error Number 2455 occurred: You entered an expression that has an invalid reference to property Form/Report"
Please advice/help
When we are trying to set properties of a subform in Access we get the following error message.
"Error Number 2455 occurred: You entered an expression that has an invalid reference to property Form/Report"
Please advice/help
strProjTypesSQL = "SELECT " _
& "[Form Name], " _
& "[View Name], " _
& "[Description], " _
& "[Major Projection Type], " _
& "[Proj Screen Info] " _
& "FROM [Projection Types] " _
& "WHERE (" _
& "([ID]='" & Me.cboDataType & "'))"
rstProjTypes.Open strProjTypesSQL, gconARS, adOpenForwardOnly, adLockReadOnly
'Load Subform
[txtSubFormLink].ControlSource = "[ID]"
[Projections Subform].SourceObject = rstProjTypes![Form Name]
[Projections Subform].Form.RecordSource = rstProjTypes![View Name] /* Access throws error in this statement */
[Projections Subform].Form.OrderBy = "[Underwriting Year]"
Me![Projections Subform].Form.OrderByOn = True
http://www.mvps.org/access/forms/frm0031.htm
To expand on the link Jim has posted:
You must refer to an Access subform using syntax similar to this:
Me.NameOfYourSubformCONTRO L.Form.Con trolProper tyEtc
Where "NameOfYourSubformCONTORL" is the name of the Subform Control on your Parent form, and may or may NOT be named the same as the form you're using as a Subform. So to set the Recordsource of your subform, IF the subform CONTROL in named the same as the form used as a subform (i.e. Projections Subform):
Me.[Projections Subform].Form.Recordsource = rstProjType("View Name")
It appears, however, from where the error is thrown that you might be referring to your subform correctly (since an incorrect reference should have thrown an error on the line above where you indicate) so the question now is:
Does rstProjType("View Name") return a VALID RecordSource item (i.e. the name of a Query, TAble or a valid SQL statement).
You must refer to an Access subform using syntax similar to this:
Me.NameOfYourSubformCONTRO
Where "NameOfYourSubformCONTORL"
Me.[Projections Subform].Form.Recordsource
It appears, however, from where the error is thrown that you might be referring to your subform correctly (since an incorrect reference should have thrown an error on the line above where you indicate) so the question now is:
Does rstProjType("View Name") return a VALID RecordSource item (i.e. the name of a Query, TAble or a valid SQL statement).
ASKER
Tried all possible options as described in the link. It didn;t work .
rstProjType("View Name") is returning a table
Here is more information as shown in the code: The issue is happening Access 2003, same code works perfect in Acccess97.
Main form has a sub form "Subform1" , From main form setting SourceObject for sub form to another sub form "Subform2" and then setting the RecordSource for Projections Subform.Form.
Can you share your thoughts?
rstProjType("View Name") is returning a table
Here is more information as shown in the code: The issue is happening Access 2003, same code works perfect in Acccess97.
Main form has a sub form "Subform1" , From main form setting SourceObject for sub form to another sub form "Subform2" and then setting the RecordSource for Projections Subform.Form.
Can you share your thoughts?
Access 97 and Access 2003 are wildly different animals ...
<Main form has a sub form "Subform1">
Is "Subform1" the name of the Subform Control on the main form? That's the key ....
You might also try setting the return from your recordset to a variable, then set that variable as the Recordsource:
'Load Subform
Dim sRS As String
sRS = rstProjTypes("View Name")
[txtSubFormLink].ControlSo urce = "[ID]"
[Projections Subform].SourceObject = rstProjTypes![Form Name]
[Projections Subform].Form.RecordSource = sRS '/ rstProjTypes![View Name] /* Access throws error in this statement */
<Main form has a sub form "Subform1">
Is "Subform1" the name of the Subform Control on the main form? That's the key ....
You might also try setting the return from your recordset to a variable, then set that variable as the Recordsource:
'Load Subform
Dim sRS As String
sRS = rstProjTypes("View Name")
[txtSubFormLink].ControlSo
[Projections Subform].SourceObject = rstProjTypes![Form Name]
[Projections Subform].Form.RecordSource
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.