Link to home
Start Free TrialLog in
Avatar of bokaria
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
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

Open in new window

Avatar of jmoss111
jmoss111
Flag of United States of America image

Avatar of Scott McDaniel (EE MVE )
To expand on the link Jim has posted:

You must refer to an Access subform using syntax similar to this:

Me.NameOfYourSubformCONTROL.Form.ControlPropertyEtc

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).
Avatar of bokaria
bokaria

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?

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].ControlSource = "[ID]"
    [Projections Subform].SourceObject = rstProjTypes![Form Name]
    [Projections Subform].Form.RecordSource = sRS '/ rstProjTypes![View Name]  /*  Access throws error in this statement */
ASKER CERTIFIED SOLUTION
Avatar of bokaria
bokaria

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial