Results 1 to 6 of 6
  1. #1
    jbeets is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2020
    Posts
    94

    Error when attempting to open report

    Hello!

    I am working on a form which uses the selection in a combo box to open a subreport. The code works when I use it to open another form but when I try and use it to open a report I get "Run time error 2101 - The setting you entered isn't valid for this property"

    This is the specific code it calls out in the debug:

    Code:
    Private Sub cboSource_AfterUpdate()
    If Me.cboSource.Value = "" Then
    End
    Else
    Me.Child59.SourceObject = Me.cboSource
    End If
    End Sub

    This is the rest of the code in case:

    Code:
    Option Compare Database
    Option Explicit
    
    Private Sub cboSource_AfterUpdate()
    
    If Me.cboSource.Value = "" Then
    End
    Else
    Me.Child59.SourceObject = Me.cboSource
    End If
    End Sub
    
    Private Sub cboSource_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    Me.cboSource.SetFocus
    Me.cboSource.Dropdown
    End Sub
    
    Private Sub Form_Load()
    
    Me.lblInfo.Caption = "Dashboard"
    
    DoCmd.Maximize
    
    Me.SummaryBox.Visible = False
    Me.CoverageBox.Visible = False
    Me.InvestigationBox.Visible = False
    Me.ScopeBox.Visible = False
    Me.ReservesBox.Visible = False
    Me.AssetBox.Visible = False
    Me.ComplianceBox.Visible = False
    Me.VendorBox.Visible = False
    Me.DataBox.Visible = False
    Me.DocBox.Visible = False
    Me.ClaimBox.Visible = False
    Me.ManagerBox.Visible = False
    
    End Sub
    
    Private Sub btn_Summary_Click()
    
    Me.ReportValue.Value = 1
    Me.cboSource.RowSource = "SELECT [tbl_Source].[ReportName] FROM" & _
                " tbl_Source WHERE ReportValue = " & Me.ReportValue & _
                " Order By ReportValue"
    Me.cboSource.SetFocus
    Me.cboSource.Dropdown
    Me.lblInfo.Caption = "Summary Results"
    Me.SummaryBox.Visible = True
    Me.CoverageBox.Visible = False
    Me.InvestigationBox.Visible = False
    Me.ScopeBox.Visible = False
    Me.ReservesBox.Visible = False
    Me.AssetBox.Visible = False
    Me.ComplianceBox.Visible = False
    Me.VendorBox.Visible = False
    Me.DataBox.Visible = False
    Me.DocBox.Visible = False
    Me.ClaimBox.Visible = False
    Me.ManagerBox.Visible = False
    End Sub
    Anyone have an idea as to what is wrong here?



    Thank you for your help!

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    if this is a subreport on a form, the sourceobject needs to be

    report.nameofreport

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by jbeets View Post
    I am working on a form which uses the selection in a combo box to open a subreport. The code works when I use it to open another form but when I try and use it to open a report I get "Run time error 2101 - The setting you entered isn't valid for this property"
    First, there are better ways to write the cboSource afterUpdate code. As is, it will ALWAYS fall through the the "Me.Child59.SourceObject = Me.cboSource".
    1st method:
    Code:
    Private Sub cboSource_AfterUpdate()
        If Len(Trim(Me.cboSource & "")) = 0 Then
            End
        Else
            Me.Child59.SourceObject = Me.cboSource
        End If
    End Sub
    You don't need the ".Value" because the value property is the default property.

    Best way:
    Code:
    Private Sub cboSource_AfterUpdate()
        If Len(Trim(Me.cboSource & "")) > 0 Then
            Me.Child59.SourceObject = Me.cboSource
        End If
    End Sub




    Back to the error message. You cannot/do not open a subReport. A Subform/Subreport is a form/report that is embedded in a form/report by using the Subform/Subreport control. When you open the main form/main report, the subform/subreport is automatically populated ("OPENED").
    Looking at the code, you have a Subform/Subreport object on a form based on this line of code:
    Code:
            Me.Child59.SourceObject = Me.cboSource
    "Me" is shorthand to refer to the current form. Otherwise you would have to use "Forms!YourFormName.Child59.SourceObject".

    The problem is the "Me.cboSource". You haven't said what the data is in the combo box.


    Changing the "Subform/Subreport" SourceObject requires a specific format for the source object.
    The object MUST already exist.For FORMS, just use the form name.
    For TABLES, QUERIES and REPORTS, the object type must be prepended.

    To change the source object to "Table1", the format would be "Table.Table1".
    To change the source object to "EmployeeList", the format would be "Report.EmployeeList".
    To change the source object to "qryStudents", the format would be "Query.qryStudents".

  4. #4
    jbeets is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2020
    Posts
    94
    Thank you both for the advice!

    I fixed the code as suggested for the After Update event.

    I also changed the combo box to say "Report.ReportName" and that worked!!!

    The combo box is a list of available reports based on the selected button. For example I have a button "Summary Results" when clicked the combo box populates a list of available Summary Reports. When the user selects one of the reports it should open in the subreport field. With your instructions I fixed that but when the user selects from the combo box they will see "Report.Summary" for example. Is there a way I can modify it so that the user sees"Summary" but the code reads the "Report.Summary"?

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    subform.sourceobject="Report." & cboSource

  6. #6
    jbeets is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2020
    Posts
    94
    Genious! Thank you so much!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Attempting to change the same data error
    By Huddle in forum Access
    Replies: 5
    Last Post: 12-21-2018, 01:05 PM
  2. Error code when attempting to View Report
    By Robert2150 in forum Access
    Replies: 3
    Last Post: 06-19-2018, 11:44 AM
  3. Replies: 10
    Last Post: 02-02-2017, 05:09 AM
  4. Replies: 1
    Last Post: 09-22-2016, 05:05 AM
  5. Error Attempting to Export Data to IE9
    By Angrybox in forum Programming
    Replies: 9
    Last Post: 06-29-2012, 03:50 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums