I added a Parameter to report.rdlc called "ReportTitle". It is text and allows blank values and nulls. I have tried different ways to pass the parameter value to no avail. This is what I've tried so far:
Dim parReportParam1 As New ReportParameter("ReportTitle", "THIS IS MY TITLE")
ReportViewer1.LocalReport.SetParameters(New ReportParameter() {parReportParam1})
Does not work!
Dim params(0) As Microsoft.Reporting.WinForms.ReportParameter
params(0) = New Microsoft.Reporting.WinForms.ReportParameter("ReportTitle", "THIS IS MY TITLE")
ReportViewer1.LocalReport.SetParameters(params)
Nothing!
Dim params(0) As Microsoft.Reporting.WinForms.ReportParameter
params(0) = New Microsoft.Reporting.WinForms.ReportParameter
params(0).Name = "ReportTitle"
params(0).Values.Add("THIS IS MY TITLE")
ReportViewer1.LocalReport.SetParameters(params)
Nope!
I don't know what to try anymore. Do I have to set something on the reportviewer or on the designer to allow parameter values. Any help is greatly appreciated it.
I found The Aswer, You need to remember to put parameters after you pick the path to the Report never before.
I had exacly the same problem, everything was fine till I put parameters to the Raport and I had spent two hours before I found the cause.
This worked for me:
Dim paramStoreNo As New ReportParameter("StoreNo", iSTORE_NO)
Dim reportparameters() As ReportParameter = {paramStoreNo}
InventoryTableAdapter.Fill(Me.DataSet1.Inventory, iSTORE_NO)
Me.ReportViewer1.LocalReport.SetParameters(reportparameters)
Me.ReportViewer1.RefreshReport()
Maybe accidentally you have set available values for parameter to just null or some other values in report.rdlc. If so goto parameter properties and set Available Values to None and try again.
If your problem is that you cant see your parameter value at your report, Can you try adding a refresh in your report viewer code page.
Add this at the end of your code
Reportviewer.localreport.refresh()
The problem might be because the page loaded before the application finished passing the values, so refresh it so it can reload with the parameter values at hand.
I used the following code and it works fine:
For Each param As WinForms.ReportParameterInfo In ReportViewer1.LocalReport.GetParameters()
If param.name = "ReportTitle" Then
ReportViewer1.LocalReport.SetParameters(New WinForms.ReportParameter(param.Name, "THIS IS MY TITLE"))
End If
Next
Me.ReportViewer1.RefreshReport()
Related
I am trying to create a macro that will copy a table and its associated queries for each year's equipment audit. I copied some code that I found on another forum, but I receive the error in the title on one line. I'm not familiar enough with VBA to understand what the problem is, so I'm hoping I can get some help.
This code is supposed to replace the source table on a copied query so that the queries don't have to be remade each year. Here is the code:
Sub UpdateQuery(QueryName, CurrentSourceTable, NewSourceTable)
Dim strQryName, strCTbl, strNTbl, strCsql, strNsql As String
Dim defqry As DAO.QueryDef
strQryName = QueryName
strCTbl = CurrentSourceTable
strNTbl = NewSourceTable
Set defqry = CurrentDb.QueryDefs(strQryName)
strCsql = defqry.SQL
strNsql = Replace(strCsql, strCTbl, strNTbl)
defqry.SQL = strNsql
defqry.Close
End Sub
The error occurs on the "Set defqry" line. Can anyone tell me what is causing the error?
ETA:
When I try to run the code above, I'm also using the following code to fill in QueryName/CurrentSourceTable/NewSourceTable:
Sub Proc1()
Call UpdateQuery(YYYY_Count_of_items_by_floor, Building_Audit_2021, Building_Audit_YYYY)
End Sub
Again, I did not write this code, I copied code that someone else had written and am attempting to use it for what I need.
Thanks, HansUp! YYYY_Count_of_items_by_floor is indeed the name of the query, so enclosing it in quotes was all that I needed to do.
i want to execute a .exe in a SSRS Report from Microsoft Dynamics AX.
I tried so far to realize that over Custom Code and a Textfield with following Expression: =Code.StartProcess("test")
Public Function StartProcess(ByVal s As String) As String
Dim pHelp As New ProcessStartInfo
pHelp.FileName = "test.bat"
pHelp.Arguments = s
pHelp.UseShellExecute = True
pHelp.WindowStyle = ProcessWindowStyle.Normal
Dim proc As Process = Process.Start(pHelp)
Return "it works"
End Function
I get the error ":StartProcess is invalid. InvalidIdentifier"
As second try i use this:
="javascript:void(window.open('file://AX2012R2A/Share/batch.exe'))"
in an action expression.
This trial opened in the report the following message by clicking on the image:
My problem is now that I have to pass a parameter to the batch and then it doesn't work.
Have you any idea to help me?
I have solved my Problem.
As first step I mentioned, that also simple methods like:
Public Function StartProcess(ByVal s As String) As String
Return "it works"
End Function
brought the error: ":StartProcess is invalid. InvalidIdentifier"
As second step i found this link:
Link to Google Group discussion
(perhabs you have to expand all messages).
As last step i have to create a Datamethod and then call it in an expression and it works.
The code in the datamethod isn't in VB.Net but in C#.
How this works, can you see here (Youtube)
Thank you all for your help.
I have searched high and low for a fix to this, so I apologize in advance if this is a dumb question or a repeat question.
So I have this Crystal Report, no I unfortunately do not know the version I'm on, that works most of the time and randomly breaks under the exact same conditions as when it works. On the times that it breaks, when I go to set the parameter with ApplyCurrentValue, it immediately pops up a window that asks for all parameters (as if none were set). When I press exit, it breaks with
System.NullReferenceException: Object reference not set to an instance
of an object. at
CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition.ApplyCurrentValues(ParameterValues
currentValues)
Below is the code. Also, every parameter I pass is the correct value so none of them are null and actually have a value.
rpt.SetDataSource(ds)
crv.ReportSource = rpt
AddCrystalReportParameters("EntityName", entityName)
AddCrystalReportParameters("dtFrom", datFrom.ToShortDateString())
AddCrystalReportParameters("dtTo", datTo.ToShortDateString())
AddCrystalReportParameters("RectEntityDesc", rectEntityDesc)
Here is the method that I use.
Sub AddCrystalReportParameters(ByVal sFieldName As String, ByVal sValue As String)
Dim discreteValue As New ParameterDiscreteValue()
Dim values As New ParameterValues()
values = rpt.DataDefinition.ParameterFields(sFieldName).CurrentValues()
discreteValue.Value = sValue 'Assign parameter
values.Add(discreteValue)
rpt.DataDefinition.ParameterFields(sFieldName).ApplyCurrentValues(values)
End Sub
Because it is so random for when it breaks, it has made testing it extremely difficult. I was thinking that maybe the report isn't loaded, but I checked for rpt.IsLoaded in which it said it was even though it went on to break when it went to add the parameter.
Thanks for your help!
You do not need to set parameters if you are setting the datasource using SetDataSource
First Create Parameters in the report itself with names (EntityName,dtFrom,dtTo and RectEntityDesc) as you described. then add these parameters to your report as objects then in the code you can set the values as code below:
rpt.SetParameterValue("#EntityName", EntityName)
rpt.SetParameterValue("#dtFrom", dtFrom.SelectedDate)
rpt.SetParameterValue("#dtTo", dtTo.SelectedDate)
rpt.SetParameterValue("#RectEntityDesc", rectEntityDesc)
this code used because you have already added the parameters to the report you are only setting the value of each parameter.
I'm trying to get information about specific branches in TFS, so to start, I'm trying to create a variable to assign as a BranchHistoryTreeItem. However, when I pass in the ItemSpec, I'm getting an error on Spec (not the definition, but where it's passed into GetBranchHistory):
Value of type 'Microsoft.TeamFoundation.VersionControl.Client.ItemSpec' cannot be converted to '1-dimensional array of Microsoft.TeamFoundation.VersionControl.Client.ItemSpec'
I understand the error, but I'm not entirely sure why it throwing it. Isn't this data type exactly what it's looking for? I believe I have the ItemSpec declared correctly, but I'm a bit lost here. Can anyone offer some advice on why I'm getting this? Code:
Sub GetBranchInfo()
Dim tfs As New TfsTeamProjectCollection(Common.BuildServerURI)
Dim Version = tfs.GetService(Of VersionControlServer)()
Dim Spec As New ItemSpec("$/Project1", RecursionType.None)
Dim BranchHistory As New BranchHistoryTreeItem(Version.GetBranchHistory(Spec, VersionSpec.Latest))
End Sub
GetBranchHistory takes an array of ItemSpecs.
My VB is a little rusty, but I think you want something like:
Dim Spec As New ItemSpec("$/Project1", RecursionType.None)
Dim Specs(1) = new ItemSpec() {Spec}
Dim BranchHistory As New BranchHistoryTreeItem(Version.GetBranchHistory(Specs, VersionSpec.Latest))
Ok I have a reportviewer that has worked perfectly up untill now, now all of a sudden it never gets past the "Report is being generated" message. The code up untill the Report.RefreshReport() is exactly and works just fine, it creates a DataSource for the report, the report itself has also not changed.
Anybody ever had this problem before and know what might be wrong with it.
Thanks in advance for all who reply!
Code segment:
Dim myemployeedetails As String() = Split(Me.ToolStripComboBox2.SelectedText, ",")
Dim paramlist As New List(Of Microsoft.Reporting.WinForms.ReportParameter)
Dim param1 As New Microsoft.Reporting.WinForms.ReportParameter("StartDate", Startdate)
Dim param3 As New
Microsoft.Reporting.WinForms.ReportParameter("EmployeeParam", Trim(myemployeedetails(1)))
paramlist.Add(param1)
paramlist.Add(param3)
Me.ReportViewer1.LocalReport.SetParameters(paramlist)
Me.CompanyCollectionBindingSource.DataSource = CompanyCollection.GetCompanys(GroupID, Startdate)
Me.ReportViewer1.RefreshReport() 'Sticks here!
Try running the query that populates your report outside of the ReportViewer context ( say, in Management Studio ).
If your calling code hasn't changed and your report hasn't changed, your data ( and retrieval of said data ) should be high on your inspection list.
Turns out the domain for an image has been changed, so the report couldnt find the image. Didnt know this because the guy that sorts that out is snowed in. Sorted now, thankyou for your quick reply Paul.
Try to verify the postback in the Page_Load() event,
if (!IsPostBack)
{
CallReportHere() //I recommend a method for all the operations related with the ReportViewer control
}
Only refresh the report if !IsPostBack, the problem is related with setting the parameters values. This problem appears with the VS2010 and continues with VS2012, specially when you migrated your solution from VS2008.
That worked for me.