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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding controls to DataReport dynamically? 1

Status
Not open for further replies.

tatsidis

Programmer
May 4, 2004
5
GR
I want to add a control to a DataReport dynamically, lets say a RptTextBox.

I run this code but i get a compile error: Method or member not found (Add is marked):

Set rptText = DR.Sections("Section1").Controls.Add("MSDataReportLib.RptTextBox", "RptTextBox1")

Does anybody knows how can i do this?
 
I don't believe that you can add controls to the DataReport at runtime. You can however add it at design time and change it's visible property to false or true at runtime as required.
[tt]
DR.Sections("Section1").Controls.("RptTextBox1").Visible = True[/tt]

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Well, I understand what you are saying, but if the user selects any number of fields he wants to print, then how can I at run-time resize the width property of a RptTextBox (for example) so that he gets a nice and visible report?

How can I know the maximum width of a field so that I can resize the RptTextBox width property to that maximum number?

Thanks for your concern and time!
 
Have a look at the CanGrow property. Otherwise you'll need to do a tedious search through the recordset looking for the longest string and working out a suitable length from there.

Otherwise use a more heavyweight report tool, such as Crystal (by Business Objects). There are Crystal forums elswhere on this site.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Hey guy. Check this out:

Dim aAccess as new Accces.Application

aAccess.CreateReportControl myReport, acTextBox, acDetail

There you go. Text box created at runtime. Then you just need to set the properties of this mug.
 
Welcome to Tek-Tips, thlibo, and thanks for the response. We look forward to more posts from you along the way. To get the best from the forum, try faq222-2244, where you'll find some usage guidelines.

This particular question was actually about the VB DataReport control, rather than an Access report. (This is the VB Databases forum)

If you're more into Access than VB, there are several other forums dealing specifically with Access noted in the <Related Forums> panel at the right hand side of the page

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top