Murray Brown
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER