Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Access List Controls in Report

Hi. I am using the following Access code to load all the controls in a Form or Report
to a Combobox. The Form  part works but the Report part doesn't because opening the report
causes it to run and I get the error "The report name you entered is misspelled or refers to a report that isn't open or doesn't exist"

    If sFormOrReport = "Form" Then
        DoCmd.OpenForm CT, , , , , acHidden
        Set frm = Forms(CT)
        For Each ctl In frm.Controls
            If ctl.ControlType = acTextBox Then
                Me.cmbControls.AddItem (ctl.Name)
            End If
        Next
        DoCmd.Close acForm, CT
    Else
        DoCmd.OpenReport CT, , , , , acHidden
        Set rpt = Reports(CT)
        For Each ctl In rpt.Controls
            If ctl.ControlType = acTextBox Then
                Me.cmbControls.AddItem (ctl.Name)
            End If
        Next
        DoCmd.Close acReport, CT
    End If
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

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
SOLUTION
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
Avatar of Murray Brown

ASKER

Great. Thanks