Sunday, March 25, 2012
Custome code not working in Report manager
I have Written the Custom code to compare two different dates and
show a message Box depending on their values .It was Working Fine in
preview tab.But it is not working when i deploy to web.Only rhe message
box part is not working in Web
I do have the Custom code like this
Public Function Errorbox(ByVal s as Date,ByVal s1 as Date) As String
If s>s1 Then
System.Windows.Forms.MessageBox.Show("From Date is greater than
To Date,Please Click Ok" )
End if
Return "a"
End Function
and i gave a text box (Just a text box)
To call this custome code and i gave the expression
=Code.Errorbox(Parameters!FROM_DATE.Value,Parameters!TO_DATE.Value)
i added this Assembly also
"System.Windows.Forms"
Its not working in Report manager(web) .Can any body help me out to
knowwhat would be the Problem.i am very new to this VB Coding
Thank you
Raj Deep.AYou need to add the assembly to the following folders:
C:\Program Files\Microsoft SQL Server\80\Tools\Report Designer
C:\Program Files\Microsoft SQL Server\MSSQL\Reporting
Services\ReportServer\bin
Hope this helps.
"RajDeep" wrote:
> Hi all,
> I have Written the Custom code to compare two different dates and
> show a message Box depending on their values .It was Working Fine in
> preview tab.But it is not working when i deploy to web.Only rhe message
> box part is not working in Web
> I do have the Custom code like this
> Public Function Errorbox(ByVal s as Date,ByVal s1 as Date) As String
> If s>s1 Then
> System.Windows.Forms.MessageBox.Show("From Date is greater than
> To Date,Please Click Ok" )
> End if
> Return "a"
> End Function
> and i gave a text box (Just a text box)
> To call this custome code and i gave the expression
> =Code.Errorbox(Parameters!FROM_DATE.Value,Parameters!TO_DATE.Value)
> i added this Assembly also
> "System.Windows.Forms"
> Its not working in Report manager(web) .Can any body help me out to
> knowwhat would be the Problem.i am very new to this VB Coding
> Thank you
> Raj Deep.A
>
Tuesday, March 20, 2012
Custom sorting
Function SortTypeValue() As String
If Report.Parameters!SortType.Value = "1" Then
Return "=Fields!StockDesc.Value"
else Return "=Fields!StockCode.Value"
End If
End Function
Then in the sorting tab I have entered in the expression field: =Code.SortTypeValue().
However this is not doing anything. The data is just displayed in the order it is taken from the database. Can this be done? If so can anybody please tell me what I am doing wrong?
Thanks in advance.
Dynamic use of parameters for grouping can be achieved using the following syntax:
=Fields(Parameters!ParamName.Value).Value
Maybe this will also work for sorting
--
Your code is going to return the same value regardless of sort type anyway.
=Fields!StockDesc.Value
You don't need it if the above method works.
--
You can set interactive sorting so the user can sort on any column they wish:
right click on the column header
interactive sort
tick tickbox
set sort expression to the value held in that particular column (i.e. if column is sales amt then =fields!salesamt.value)
done
if you need to do this for a whole raft of columns, it is quicker to do it in the (F4) properties window:
expand the 'user sort' propery and set the 'sort expression' drop down as per the column name
NB keep sort expression selected otherwise when you click on the next column you wish to add a sort to, the properties collapse|||You say my code will return the same value regardless of sort type anyway. Why? Each condition returns a different string.
If I was to use =Fields(Parameters!ParamName.Value).Value I would still need a way to determine which column the user wants to sort on so I know which ParamName to insert.|||To paraphrase the jerky boys "my eyes is going crazy"
but you still don't need the code anyway.
With regards to using my technique for sorting.....
It works.
I just created a very simple report.
I added one parameter called 'sort by'
I just set the values of this to the names of the db columns returned. Spelling exactly as per db cols!
In the table, sorting tab, i just added this
=Fields(Parameters!sortby.Value).Value
go to the preview, Pick your column name, run
simple|||
One step further. . .
Create the parameter as described by "adolf garlic" and also create a parameter named "SortDirection" and give the parameter values "Ascending" and "Descending"
In the table/sort "Expression" field(s) enter:
=Iif(Parameters!SortDirection.Value = "Ascending", Fields(Parameters!SortBy.Value).Value, "")
=Iif(Parameters!SortDirection.Value = "Descending", Fields(Parameters!SortBy.Value).Value, "")
and set the proper direction for both expressions.|||Thanks adolf garlic. Works like a treat. Exactly what I was after.sql
Thursday, March 8, 2012
Custom Grouping Problem
Function OrganisationGroup() As String
Dim Group As String
Group = ""
Select Case Report.Parameters!EnterpriseOption.Value
Case "1"
Group = Group1Value()
Case "2"
Group = "DepartmentDesc"
Case "3"
Group = "OrganizationDesc"
Case "4"
Group = "OrganizationDesc"
End Select
If Group = "" Then
Return "0"
Else
Return "Fields!" & Group & ".Value"
End If
End Function
Function Group1Value() As String
Dim Group As String
Group = ""
Select Case Report.Parameters!ReportType.Value
Case "1"
Group = "StockFamilyDesc"
Case "2"
Group = "GroupDesc"
Case "3"
Group = "Saleable"
Case "4"
Group = "Saleable"
Case "5"
Group = "SaleableGLCodeDesc"
Case "6"
Group = "Saleable"
End Select
Return Group
End Function
Does anyone have any ideas on why the grouping would not be working with the custom function?
Thanks in advance.
I have solved the problem myself. The following changes to the custom code fixed the problem.
Function Group1Value() As String
Dim Group As String
Group = ""
Select Case Report.Parameters!ReportType.Value
Case "1" Group = "StockFamilyDesc"
Case "2" Group = "GroupDesc"
Case "3" Group = "Saleable"
Case "4" Group = "Saleable"
Case "5" Group = "SaleableGLCodeDesc"
Case "6" Group = "Saleable"
End Select
Return Group
End Function
Now is ...
Function Group1Value(fields As Fields) As String
Dim Group As String
Group = ""
Select Case Report.Parameters!ReportType.Value
Case "1" Group = fields!StockFamilyDesc.Value
Case "2" Group = fields!GroupDesc.Value
Case "3" Group = fields!Saleable.Value
Case "4" Group = fields!Saleable.Value
Case "5" Group = fields!SaleableGLCodeDesc.Value
Case "6" Group = fields!Saleable.Value
End Select
Return Group
End Function
Similar changes in Function OrganisationGroup()
Custom Grouping Problem
Function OrganisationGroup() As String
Dim Group As String
Group = ""
Select Case Report.Parameters!EnterpriseOption.Value
Case "1"
Group = Group1Value()
Case "2"
Group = "DepartmentDesc"
Case "3"
Group = "OrganizationDesc"
Case "4"
Group = "OrganizationDesc"
End Select
If Group = "" Then
Return "0"
Else
Return "Fields!" & Group & ".Value"
End If
End Function
Function Group1Value() As String
Dim Group As String
Group = ""
Select Case Report.Parameters!ReportType.Value
Case "1"
Group = "StockFamilyDesc"
Case "2"
Group = "GroupDesc"
Case "3"
Group = "Saleable"
Case "4"
Group = "Saleable"
Case "5"
Group = "SaleableGLCodeDesc"
Case "6"
Group = "Saleable"
End Select
Return Group
End Function
Does anyone have any ideas on why the grouping would not be working with the custom function?
Thanks in advance.
I have solved the problem myself. The following changes to the custom code fixed the problem.
Function Group1Value() As String
Dim Group As String
Group = ""
Select Case Report.Parameters!ReportType.Value
Case "1" Group = "StockFamilyDesc"
Case "2" Group = "GroupDesc"
Case "3" Group = "Saleable"
Case "4" Group = "Saleable"
Case "5" Group = "SaleableGLCodeDesc"
Case "6" Group = "Saleable"
End Select
Return Group
End Function
Now is ...
Function Group1Value(fields As Fields) As String
Dim Group As String
Group = ""
Select Case Report.Parameters!ReportType.Value
Case "1" Group = fields!StockFamilyDesc.Value
Case "2" Group = fields!GroupDesc.Value
Case "3" Group = fields!Saleable.Value
Case "4" Group = fields!Saleable.Value
Case "5" Group = fields!SaleableGLCodeDesc.Value
Case "6" Group = fields!Saleable.Value
End Select
Return Group
End Function
Similar changes in Function OrganisationGroup()