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

Datareport Control Object

Status
Not open for further replies.

judyscofield

Programmer
Sep 24, 2001
56
0
0
US
I have asked this before and got no response, so maybe this is worded better.

I'm trying to set the font attribute of a control in a datareport in code based on user input. If I code, for example,

drReport1.Sections("Section1").Controls("Text1").Font.Bold = True

it sets ALL the controls on the report to font.bold = true. I've tried using the name of the control in quotes as above and the number of the control. I just want the one control set - what amI doing wrong?

Judy Scofield
 
I've never had any luck referring to the objects by name; I've always had to refer to them by an index number. I've never set a font attribute, but I have modified text on the reports at runtime...

For example, some code in the Initialize event in a report of mine is:
Code:
Me.Sections(1).Controls.Item(2).Caption = strLocation & " Coil Inventory"

If this doesn't help, I can make some time to play around with my reports tomorrow. Good luck.


On another note, the built in data reports that come with Visual Basic are quite horrid from my experience. I'm trying to move away from them and into some other software. If this is an option you have, maybe it should be considered?
 
I actually build my reports in Crystal 9 and agree that the datareport leaves much to be desired. This report is very unusual and was inherited from an Access program. Time constraints are making it difficult to rewrite.

I also reset captions in this report and it works fine on individual controls. I tried using .Item as in your sample, but it still doesn't work. It's either all or nothing.

Let me know if you have a chance to try this out.

Judy Scofield
 
Here's what I'm noticing as I play with this...

It doesn't matter whether I refer to the objects by name or by number (referring by name seems to work now; I must have been doing something wrong when I last played with it... go figure). When I set a control named "Text1" to
Code:
Font.Bold = True
, it's setting that attribute for every instance of Text1 that is used in the report. However, it's not affecting all of the controls on the report.

Judy, you said originally that it's affecting all of the controls. I just want to verify if that's what is happening.

--
Jonathan
 
Yes, it's affecting all of the controls. I happen to 0nly have one instance of "Text1". Is affects all the controls whether I refer to them by name or number and it even crosses sections, setting the contorls in the report header as well as the detail section.

Judy
 
I wish I could help more, but I haven't been able duplicate the problem.

When I set a control's bold attribute to true in one section, it only sets its own bold attribute to true and the bold attribute of every other instance of itself that is created at run time.

If I run across something that might help, I'll be sure to post.

Good luck, Judy.

--
Jonathan
 
Thanks - I can set different attributes at design time. I only run into the problem when I'm trying to change the attribute of one control at run time. Let me know if you think of anything else.

Judy Scofield
 
I'm setting the attribute at run time as well just without that same problem. I'm going to scour the knowledgebase looking for direction shortly.

--
Jonathan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top