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

Setting captions for labels on data report...

Status
Not open for further replies.

GWhiz

Programmer
Joined
Dec 16, 1999
Messages
49
Location
US
Sheesh – I run into more problems trying to do simple things!<br>
<br>
I'm designing a data report to print test data from testing circuit boards. The serial number and job number of the tested board must appear on the test report. This is usually not known 'til run time. The test program prompts the user to enter the serial number and job number through pop-up dialog boxes. S/n and j/n are stored in variables until the test report is printed.<br>
<br>
I want the s/n and j/n to appear in the report header. VB allows only labels (not text boxes) in the header section. So it seems a simple task to set the .Caption property of the labels to the value of the stored variables when the report is printed.<br>
<br>
NOT!<br>
<br>
Have tried to set values for captions on labels in Activate or Initialize events when Data Report is opened, but VB won't let me do that, and won't tell me why.<br>
<br>
Got holes in my scalp from scratching my head on this one.<br>
<br>
Any suggestions?<br>

 
When you say &quot;report&quot; what are you using to create the report?<br>
Generally to add info to a label at runtime is<br>
<br>
label1.caption = &quot;S/N &quot; & Variable1 & &quot; J/N &quot; & Variable2<br>
<br>
which will look like this when put in a label<br>
<br>
S/N 12345 J/N 098765<br>
<br>
Hope this Helps
 
Tnx for response, DougP.<br>
<br>
I'm using a DataReport. Can set captions of labels on Forms as you suggest with no problem. But having no luck setting label captions on Reports using same.<br>
<br>
&quot;Reports&quot; and &quot;Forms&quot; are two different monsters -- &quot;Forms&quot; more for direct realtime interaction with screen/computer and &quot;Reports&quot; more for printouts.<br>
<br>
Caption of labels on Report must be set prior to printout (obviously) -- seems like code in Activate or Initialize events as Report is opened should take care of that. But I haven't found the key to doing that yet.<br>
<br>
VB is a lot like the English language -- &quot;geese&quot; is plural for &quot;goose&quot;, so you'd think that &quot;meese&quot; would be plural for &quot;moose&quot;. Not.<br>
<br>
Seems simple enough. Or is that &quot;enuff&quot;? Or maybe &quot;enuph&quot;?<br>
<br>
Sometimes I LOVE VB. Moments later, it drives me up the wall.<br>
<br>
Any other suggestions?
 
GWhiz,<br>
<br>
This works for me:<br>
<br>
DataReport1.Sections(&quot;section4&quot;).Controls(&quot;label2&quot;).Caption = &quot;WooHoo!&quot;<br>
<br>
Of course my report header is section4 and my label is named Label2.<br>
<br>

 
Jerrycurl:<br>
<br>
THANK YOU S-O-O-O MUCH!!!<br>
<br>
Works like a champ!!!<br>
<br>
You're a life-saver!<br>
<br>
Hope I can return the favor someday -- if not directly to you, maybe someone else...<br>
<br>
GWhiz
 
Hi guys

Im kinda doing the same thing adding text into a label in the report header. I've tried the code Jerrycurl put but I keep getting a subscript out of range error. I know the code works as it works in the page header section but not in the report header section?

Im stumped.

any ideas?

Sw0rdfish149
 
Look at the properties window to make sure that you have the ReportHeader section and the Label name right. That always seems to give problems. It should work fine as long as you have VB SP5 installed

I just checked with:
dr1.Sections("RH").Controls("label3").Caption = "Hello"

My report is called dr1, my report header section is called rh and the label is called label3

________________________________________________________________
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