jbriggs said 1 year, 6 months ago:
I have been working with C1 for a couple of months and a lot of things are a lot clearer now.
One thing that still catches me out:
When I am producing reports I always try to name Fields and Labels, funnily enough using the (Name) property. I will always leave Text property blank. Unless it is a static label that will never change.
So If i wanted to populate a field I would use FieldA.text = "Text" etc
However, I have come accross some previously made reports that reference a field by using its Text property.
So you would have two labels:
Text = Number1
(Name) = Field1
Text = Number2
(Name) = Field2
Another field may then have:
Text = Number1 + Number2 (I would do [Field1] + [Field2])
(Name) = Field3
When they then reference the above field is when it get really confusing as they do:
Text = [Number1 + Number2] / 10
(Name) = Field4
Whereas I would do: [Field3] / 10
This other way seems to work, but can cause a lot of confusion and some times C1 looks for a record name matching the Text value in the Record Source, as some times they mix up the use of a label and a field! :S
It also works when they are referenced in this way in the vb code. However, if you reference using the Name it highlights it in grey whereas if you reference using the Text it says black. To someone who is looking through the code, it looks like the field is not present on the report.
Does anybody know of any reason or benefit to referencuing like this?
Ok my next query, again I am not sure why this done either.
Also I am not sure how popular eSightEnergy is so I will explain that just incase.
This a large data base logging data from meters. Each meter is identified via a SiteCode and a MeterCode in the form SiteCode.MeterCode
On the vast majority of reports the following is used:
SiteNum = "H123″ SiteGas.text = Sum(Value,MeterCode =" [" & SiteNum & "].[SiteGas]") 'Site Gas Corrected
However sometimes a report will for no apparent reason stop populating the fields correctly and show nothing.
If I edit the code to:
SiteGas.text = Sum(Value,MeterCode =SiteNum & ".SiteGas") 'Site Gas Corrected
It then works fine. I haven’t found a consitstent pattern yet, so times this on a main report, sometimes a sub report and sometimes very oddly it is done on the main report for a subreport!!! Like this:
subTableOpenClose1.subreport.Fields("TF1″).Text = "Sum(Value,MeterCode=""[H42305].[HV1kWh]"")+sum(Value,MeterCode=""[H42305].[HV2kWh]"")"
The above, to me, is an odd way of doing it, as you go to the subreport, alter something, preview your full report and it gets overwritten with something from the main report!!!! That has tripped me up a couple of times!!!!
Any ideas why the above would be done and why the reports sometimes don’t like the square brackets?
Mohita33p said 1 year, 5 months ago:
Apologies for delay in response.
1. I would like to specify that the 'NAME’ property of a field is it’s identifier and is use to refer that field anywhere in the report. Hence, the same also get highlighted as grey.
While 'TEXT’ is a property used to display the content in the field. If an unbound field, the text will be equal to the string provided to it and if a bound field, the text will be equal to the name of the column it is bound to in the database.
When using the name of the column as in the following :
Field4.Text = Field3 / 10
the calculated value of the field3 is retrieved, divided by 10 and show in the Field4
Since, the name is the identifier it greys while 'text’,like any other property, does not grey out.
2. Regarding your second query, it seems that you are trying to add the value of two fields, compare it to some value. And on the basis of the comparison you are setting the text of SiteGas.
Would it be possible to share with us your report xml, datasource and the sample application.
3. You also mentioned that the values from the main report overwrites the value in the subreport. Could you please specify as which values/properties are you referring to.
jbriggs said 1 year, 5 months ago:
Thank you for the reply.
The first issues I have put down to a general error and I correct it where ever I find it.
I will try and explain the second error better. Unfortunatley I can’t upload the actual files as they are confifdential and company property etc.
I will see if I can try and show the problem more clearly.
Firstly the Main Report uses a function which grabs the total of a bunch of readings for a time period from a database for every meter used on the report:
PARAMETERS FromDate string ’2012-06-30 00:00′, ToDate string ’2012-07-06 23:59′;
Now instead of filling up the main report I use subreports (as there is a lot of information).
Next step is I create a subreport and decide on the meters that will be used on that subreport.
In the OnFormat section of the Main Report I do the following:
Create a variable to hold all the meters being used:
SiteID = "England."
MetersUsed = SiteID & MeterA & "," & SiteID & MeterB
I then create and instance of the subreport on the main report and do the following, again on the On Format part of the main report.
sql = " usp_RPZGetTotalForPeriodForMeterCodes('" & MetersUsed & "', '" & dtmFromDate & "',’" & dtmToDate & "',NULL,1)"
MySubReport1.subreport.datasource.recordsource = sql
Pass in any other values I may need to the subreport as below:
MySubReport1.subreport.Fields("val_SiteID").Text = SiteID
on the sub report, again in the onformat section of where it is needed I would use the following code to display I total for the period:
SiteID = val_SiteID.text
MyTotalA =sum(Value,MeterCode="[" & SiteID & "].[MeterA]")
val_TotalMeterA.text = MyTotalA
Hope this makes sense so far, I can apprciate that it is difficult doing this with out having the document.
My question is, sometimes the above stops working, even though it has worked fine for months previously and if I alter the above code too:
SiteID = val_SiteID.text
MyTotalA =sum(Value,MeterCode="SiteID & ".MeterA")
val_TotalMeterA.text = MyTotalA
It will work perfectly fine.
Ok, the very last point, some times the above is done from the MAIN REPORT in the following way:
MySubReport1.subreport.Fields("val_TotalMeterA").Text = "sum(Value,MeterCode="SiteID & ".MeterA")"
This essentially sets the field’s text property (on a subreport) to a caluclation that is done at render, I feel this is a very messy way of doing it and I try to replace where possible.
But again sometimes for it to render a calcualted value I need the square brackts and sometimes I don’t need them.
If you can’t help that is not a problem I aware of this and it is one of things I try when I get a report that won’t ender correctly.
You must be logged in to reply to this topic.