Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically change width of control on subform

Status
Not open for further replies.

jaaret

Instructor
Jun 19, 2002
171
I have a subreport that I use in several reports. Some of the reports are vertical, others are horizontal. I want to dynamically change the width of the subreport and one of the text boxes in it depending on which main report is selected.

I think this code should work but I haven't found the event that will make it work successfully:

'Widen the width if a horizontally oriented report is selected
If Form_frmReports.cmbReportID = 75 Then
Report_rsubAttendees.Width = 14400
Report_rsubAttendees.txtNames.Width = 11880
Else
Report_rsubAttendees.Width = 10080
Report_rsubAttendeeNamesH1.txtNames.Width = 8280
End If

When I place this in with the Print Preview command button or on the main report's On Open event I receive the error:

"You can't set the width property in print preview or after printing has started"

When I place this code in the subform's On Open event I do not receive an ereror message but the width's are not affected. What event will successfully trigger this?

Thanks in advance,
Jaaret


 
You may have to open the report in design view in order to make these changes.

Also you have to consider 3 things.

The width of the control, the width of the report object that is the report and the width of the control the sub report is in.

So assuming it works on open...

Code:
If Forms!frmReports!cmbReportID = 75 Then
     Me!Report_rsubAttendees.Width = 14400
Else
     Me!Report_rsubAttendees.Width = 10080
End if

If that works you may also have success with similar code on the on open event of the subform.


Honestly, this seems like a lot of wark for 2 scenarios. I would just make a copy of the sub report and make 1 for landscape and another for portrait.
 
You need to use the OnFormat event, if you want to play with the formatting of the report.

Max Hugen
Australia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top