I have a tablix that is using RowGroups to group instances of data. A textbox in the tablix refers to a field as it relates to everything else in that group of data. I would like to create a textbox outside the group, below the tablix, and have it reference the value of that textbox inside the group. I have attempted referencing the group textbox using =ReportItems!GroupTextbox1.Value but this returns empty. Is this in anyway possible in SSRS? Thanks in advance for any assistance anyone can provide.
This scenario is probably not supported, ref http://msdn.microsoft.com/en-us/library/dd255285.aspx
If you provided some more info on what output you are trying to achieve (not just your code) we might be able to help.
Hope this helps someone:
You can use Custom code-feature of the report. Open the Report properties and then Code-tab. In there you can write or own code to save results and read them later on. The variables are in report-scope. Like:
Public Shared Dim MyValue as Double = 0
Public Function SaveMyValue (ByVal s As Double) as Double
MyValue+=s
Return s
End Function
Public Function GetMyValue() as Double
Return MyValue
End Function
And using these functions goes like this, eg. in Textbox expression:
=Code.SaveMyValue(Fields!SomeValue.Value)
Related
I want to be able to pass in a string (or array) like 1,6,33 and so on. I can easily pass in a string like this. Then within the report in a selection formula have something like:-
{fieldname} IN {?myParam}
but cannot get this to work, any suggestions on how to achieve this?
I have to format a date string to a custom format like i need to convert "11/04/2016" to "11/D/2016". simply I have to replace the month number that is here 04 to an alphabet with the same sequence like 01 will be replaced by A and 02 by B and so on. I don't have any problem for writing logic for general purpose programming language. But I dont know how to add this custom functionality in crystal report.
I have checked formula fields but it seems they have predefined formulas whereas I need custom formula.
Is there any way to add custom function in crystal report and pass it some parameter and then it returns you come data that you show on the report ???
Thanks in advance !
Go to Report --> formula workshop and there go to New and there select custom function
Syntax would be:
Create a function Convert
Function(StringVar value) //this will take the input string
//Here write your logic and return a value.and close the function
Now you have created a custom function.
To use this create a new formula in functions go to custom functions and double click already create function
Convert("11/04/2016"); //close the window and place formula on design and refresh you get required output
I'm having problem with JasperReports report by getting sum of two fields.
I have created so far variables that holds fields "TareWeight" variable that is casting values from double to float
new Float($F{EquipmentTareWeightKg})
"CargoWt" variable that is casting from string to float, etc...
Float.parseFloat($F{UfvFlexString03})+Float.parseFloat($F{UfvFlexString04})
So now I have two variables which I can manipulate with.
The problem starts when I wish to do a "recap" using crosstab. I have setup two groups that is done with wizard, and added another in crosstab. (please refer to the printscreen below)
And now, I have created under measures SumOf Tare that is using variable TareWt, and SumOfCargoWt that is using variable CargoWt.
I have tried to create another Measure SumOfGrossWt that would do a sum of variables TareWt + CargoWt but I have got some nonsense values.
I have tried to do another approach by creating variable GrossWt that would basically do exact the same thing as previous attempt
$V{Tare}+$V{CargoWt}
or use an variable: GrossWt
$V{Tare}+$V{CargoWt} or new Float($F{EquipmentTareWeightKg})+(Float.parseFloat($F{UfvFlexString03})+Float.parseFloat($F{UfvFlexString04}))
None of these actually worked: (Sum should be done by "Sum Of Tare"+ "Sum of CargoWt" = "Sum of GrossWt") plese refer to the second picture.
Here is a complete jrxml code/file:
jrxml file
save it as *.jrxml
Can please someone help me find a solution? how can I sum those two measure fields and get correct values?
Since CargoWt field had some null values in database, addition float value with null is equal to null, so the only value which was displayed on report are the one that had values for CargoWt, all others with null value were "ignored".
I have a program built with VBA, in access.
I have a form with the field chDate and I need to get the value of the field in a module file named Global (not class module).
I tried to access it but I think I get empty value, string. not error.
I'm no expert with VBA, its new to me (I have experience with VBS).
Can someone please help me and tell me how can I access the value of a form field via module file?
Thanks!
If you can provide some sample code, it might help us in trying to get you a solution.
Here's what might work:
Dim an object as an instance of your form, and set the instance to a new instance. These two lines will do that (assuming the form is called frmForm)
Dim theForm as frmForm
Set theForm = new frmForm
then Show that Form:
theForm.show
The form will get the focus, so you can populate the fields. At that point, once the form is hidden, your code should be able to pull the field as such:
var1 = theForm.txtFormField.Text
However, if you unload the form in code, all variables directly tied to the form will be lost. In that case, you might want to follow Oneide's example, and set a global variable to the value of the form field. You can do this in one of the form's event handlers.
Let me see if I can recall my Access days. In your global module you should access the form field be prefixing the form name i.e.
var1 = Form1.txtFirmField.Text
As far as I know, you're trying to get the data the wrong way.
Anytime you would try to get your form data, from a standard module, your form probably will already be closed or, if you're not opening it as a restricted window, the value will not be ready yet.
Anyway, if you could get pass through all the difficulties above, you're probably coding in a not standard / right way.
Remember that VBA is an event driven language, and you would be better using it's strenghts rather than fighting against them.
As a final word, if this is just a casual coding, I suggest you using a global variable and make de Code Behind Form have set it up on control's change event.
If you're not sure what I mean, please leave a comment and I'll try to explain it better.
And, if you don't mind, let us know more about your starting code to get better answers.
I would like to do something like add a nice-to-Excel-functions Name property to the WorkBook class. Is there a good way to do this?
More detailed problem: In VBA you can assign a formula to a range in an Excel worksheet. I want to do so, and I want my formula to refer to a second workbook, which is an object called wb in my code. I then use wb.Name in assigning a formula to a range.
The problem arises when wb.Name has a single-quote in it. Then you wind up with something like this:
=MONTH('[Ryan's WB]Sheet1'A1)
in the spreadsheet, which fails because the single-quote in the workbook name matches to the first single-quote.
What I would like is a FunName property for the WorkBook class that replaces all single-quotes in the Name property with two single-quotes and returns that. Then the above formula would properly wind up looking like
=MONTH('[Ryan''s WB]Sheet1'A1)
You don't need to make a separate class to extend the workbook class. You can add properties to the existing ThisWorkbook class module, like this:
Public Property Get FunName() As String
FunName = Replace(Me.Name, "'", "''")
End Property
Then you call ThisWorkbook.FunName to get your cleaned up name. However, this code has to exist in the workbook at hand. If you want it to work on any workbook, your function is the way to go.
Just do a replace to double up the single quotes
WorksheetName = Replace(WB.Name, "'", "''")
What you need is a Class which extends the Workbook object. Insert a class module, then try the following code
Dim WithEvents WB As Workbook
Public Sub SetWB(W As Workbook)
Set WB = W
End Sub
Public Property Get FunName() As String
FunName = Replace(WB.Name, "'", "''")
End Property
Private Sub WB_SheetCalculate(ByVal Sh As Object)
'this runs when WB calculates
End Sub
'use it like this
Dim WB As New wbClass
WB.SetWB ActiveWorkbook
CleanedName = WB.FunName
Note that as a bonus, I've put WithEvents in the line that Dims WB at the top of the class. This allows you to trap all the events that happen to WB, and I included the Calculate event as a demo above. If you are in the class code and click the objects dropdown at top left of the code pane, you'll see the WB object, and if you click this, the right hand list box will give you all the events to choose from.
The final answer appears to be that the WorkBook class can be extended to include a name property that is nice to Excel formulas. This can be done using the method provided by dbb. However, since VBA does not support inheritance, objects of the extended class will have only the properties you define for them.
Therefore, it really makes more sense to just use a function. Here's what I'm going to use:
Function FormulaWorkName(ByVal aName As String) As String
FormulaWorkName = Replace(aName, "'", "''")
End Function
Which I will apply to both worksheet names and workbook names.