We're using SSRS 2008 R2
We have several reports that call multiple stored procedures. It seems that as soon as the report is called its runs the stored procs with their default values then reruns the stored procs with the passed parameters. Does that make sense?
We're considering using snapshots to store a snapshot of report with all the default parameters but is there a better way?
rptViewer.ProcessingMode = ProcessingMode.Remote
rptViewer.ShowCredentialPrompts = False
rptViewer.ShowBackButton = False
rptViewer.ShowDocumentMapButton = False
rptViewer.ShowExportControls = False
rptViewer.ShowFindControls = False
rptViewer.EnableViewState = True
rptViewer.ShowPageNavigationControls = False
rptViewer.ShowParameterPrompts = True
rptViewer.ShowRefreshButton = False
rptViewer.ShowPrintButton = True
rptViewer.ShowPromptAreaButton = False
rptViewer.ShowToolBar = True
rptViewer.ShowZoomControl = False
rptViewer.SizeToReportContent = True
rptViewer.AsyncRendering = False
rptViewer.Height = Unit.Percentage(100)
rptViewer.Width = Unit.Percentage(100)
Dim RepParameters As New ReportParams
With RepParameters
.ApplicationID = MyBase.CurrentApplicationID.ToString
.EntityID = EntityIDList
If ShowTitle Then .isExported = "True" Else .isExported = "False"
.LanguageID = CShort(MyBase.CurrentLanguage.ID).ToString
.UserSecurityID = CInt(MyBase.CurrentLoggedUser.SecurityID).ToString
End With
**rptViewer.ServerReport.SetParameters(rep.SsrsReportParameters(RepParameters))**
Sounds like you are passing your parameters too late for the reportviewer control. Make sure in the page's execution cycle you are setting them preferably as soon as possible. I worked around this problem by initialising the ReportViewer control in the page load code behind code rather than declaring one in the aspx part. This solved it for me.
More of a workaround than a solution.
We ended up setting the default value to one of the parameters to -1 and in the stored procedure we only run the code if the parameter is not -1.
Related
I am porting a dashboard app from Access 2013 to 2019 and I cannot find the way to export charts as pictures. I've recreated the charts on forms using the new chart engine but I can't get any method to work.
I used:
Set oleGrf = Forms("zf_" & GRFile$)!Graph1.Object
oleGrf.Export "U:\datasource\dashboards\cwgraphs\" & GRFile$ & ".PNG", "PNG"
Can anyone point me at an example of some code that does it please?
I use Access 2010. This works for me:
Dim grpApp As Object
Set grpApp = Nothing
Set grpApp = Me.Graph1.Object
grpApp.Export "C:\Users\June\TestJHB.jpg"
Me.Graph1.Locked = False
Me.Graph1.Enabled = True
Set grpApp = Nothing
Me.Graph1.Action = acOLEClose
Me.Graph1.Locked = True
Me.Graph1.Enabled = False
This question isn't particularly technical, it's more theoretical.
I'm doing the "project queue" thing in Access that I think we all do from time to time. We've got several steps to go through. I'm hiding buttons that don't make sense in a given step and adding a star to the most relevant tab. For example, if I have been assigned development of a project, the "move to production" button is hidden and disabled because I need to go through testing before I can move the project to production. I also rename the development tab to Development* to queue me to that.
Everything was hardcoded in VBA and it still can be but it's getting longer and uglier to maintain. I'm wondering if someone has a best practice or just general suggestion. I had 6 statuses but I'm going to 12 and feel like it's time to think about doing this better.
When a button is clicked you get a code block like this:
Private Sub AssignScoping_Click()
Me.RequestStatus.Enabled = True
Me.RequestStatus = "Scoping"
Me.RequestStatus.Enabled = False
End Sub
Each button just assigns a different text value to the RequestStatus field which drives the rest of the logic which looks like this:
Private Sub setButtonAvailability()
Select Case Me.RequestStatus
Case Null
Me.PlaceInQueue.Visible = True
Me.PlaceInQueue.Enabled = True
Me.AssignScoping.Visible = False
Me.AssignScoping.Enabled = False
Me.AssignDevelopment.Visible = False
Me.AssignDevelopment.Enabled = False
Me.AssignTesting.Visible = False
Me.AssignTesting.Enabled = False
Me.AssignProduction.Visible = False
Me.AssignProduction.Enabled = False
Me.AssignAutomation.Visible = False
Me.AssignAutomation.Enabled = False
Me.Tabs.Pages("Intake").Caption = "Intake" & "*"
Me.Tabs.Pages("Scoping").Caption = "Scoping"
Me.Tabs.Pages("Development").Caption = "Development"
Me.Tabs.Pages("Testing").Caption = "Testing"
Me.Tabs.Pages("Production").Caption = "Production"
Me.Tabs.Pages("Automation").Caption = "Automation"
...
Case Else
Me.PlaceInQueue.Visible = True
Me.PlaceInQueue.Enabled = True
Me.AssignScoping.Visible = True
Me.AssignScoping.Enabled = True
Me.AssignDevelopment.Visible = True
Me.AssignDevelopment.Enabled = True
Me.AssignTesting.Visible = True
Me.AssignTesting.Enabled = True
Me.AssignProduction.Visible = True
Me.AssignProduction.Enabled = True
Me.AssignAutomation.Visible = True
Me.AssignAutomation.Enabled = True
Me.Tabs.Pages("Intake").Caption = "Intake"
Me.Tabs.Pages("Scoping").Caption = "Scoping"
Me.Tabs.Pages("Development").Caption = "Development"
Me.Tabs.Pages("Testing").Caption = "Testing"
Me.Tabs.Pages("Production").Caption = "Production"
Me.Tabs.Pages("Automation").Caption = "Automation"
End Select
End Sub
I figure there are a ton of options including putting some of the controlling info in a table for just that purpose but thought I'd bounce it off your collective noggins for suggestions as I tend to work in isolation at my job and I don't always think of the best way to do something, just the way I can do it right now.
Textbox and combobox can employ Conditional Formatting rules to set enabled/disabled state.
Doesn't matter what approach is taken, still have to 'touch' each control to set its property. One approach is to generically loop through controls collection without having to explicitly reference each control by name and set the Enabled or Visible properties according to some criteria. Use of control's Tag property might be helpful. Example:
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acCommandButton Then
ctl.Visible = ctl.Tag = Me.RequestStatus
End If
Next ctl
Another approach is to give controls similar name, like btnProj1, btnProj2, etc. Then loop could be limited to that set of controls:
For x = 1 to 10
Me.Controls("btnProj" & x).Visible = Me.Controls("btnProj" & x).Tag = Me.RequestStatus
Next
If you set a control not visible, why bother with the Enabled property?
I have a tabbed control (TabCtl45) in the "Detail" section of my report that that has three tabs. (Page1, Page2, Page3). I only want to show one page depending on another variable known as Fee Type. If FeeType = 1, then Page1 tab shows. If FeeType = 2, then page Page2 tab shows... etc.
I was able to make this work in "Print View" with the OnFormat event; however, I want all my data in one easy flowing page like report view. Not in separate pages like print view outputs.
The code looked like this:
If Me.FeeType = "1" Then
Me.TabCtl45.Pages("Page1").Visible = True
Me.TabCtl45.Pages("Page2").Visible = False
Me.TabCtl45.Pages("Page3").Visible = False
ElseIf Me.FeeType = "2" Then
Me.TabCtl45.Pages("Page1").Visible = False
Me.TabCtl45.Pages("Page2").Visible = True
Me.TabCtl45.Pages("Page3").Visible = False
ElseIf Me.FeeType = "3" Then
Me.TabCtl45.Pages("Page1").Visible = False
Me.TabCtl45.Pages("Page2").Visible = False
Me.TabCtl45.Pages("Page3").Visible = True
End If
How do you I get this code to work in report view from the "Detail" section of my report? There is no event that I can see working for this purpose in the properties "Detail" section.
You can't. The Report View is rather limited, the section events (like Detail.OnFormat) simply don't run in this view. Only in Print/Print Preview.
The only thing you can do to format single records in Report View is Conditional Formatting, but that's no use to hide things.
On an unrelated note, you can simplify your code a lot by doing:
Me.TabCtl45.Pages("Page1").Visible = (Me.FeeType = "1")
Me.TabCtl45.Pages("Page2").Visible = (Me.FeeType = "2")
Me.TabCtl45.Pages("Page3").Visible = (Me.FeeType = "3")
I'm working on an SSRS 2008 R2 report and I'm displaying images dynamically. I would like to hide the image box and display an icon with text that reads "Image not found" if the image doesn't exist on our report server.
I've tried a few things with expressions, but I can't get them to correctly return true or false, based on if the image exists or not.
The expression I'm using to display the image is:
="/BusinessIntelligence/Drilldown Reports/" + Fields!item.Value + ".jpg"
To test if I could get the report to detect whether the image existed, I dragged a textbox onto my report and tried the following expressions in an attempt to return True or False.
=IIf(IsNothing("/BusinessIntelligence/Drilldown Reports/" + Fields!item.Value + ".jpg"), "Woohoo!", "Do'h!") this always returns False, even if the image exists.
I even tried using some custom code I found here.
Code:
Function IsValid(ByVal Url As String) As Boolean
Dim sStream As IO.Stream
Dim URLReq As Net.HttpWebRequest
Dim URLRes As Net.HttpWebResponse
Try
URLReq = Net.WebRequest.Create(Url)
URLReq.Credentials = System.Net.CredentialCache.DefaultCredentials
URLRes = URLReq.GetResponse()
sStream = URLRes.GetResponseStream()
Dim reader As String = New IO.StreamReader(sStream).ReadToEnd()
Return True
Catch ex As Exception
Return False
End Try
End Function
And the expression I used for that code is:
=IIf(Code.IsValid("/BusinessIntelligence/Drilldown Reports/" + Fields!item.Value + ".jpg"), "Woohoo!", "Do'h!")
But this also always just returns false.
ok, I needed this thanks.
Your error here is you are using a reserve word for a webpage IsValue. Change your function name to IsThere and it should work famously.
I've inherited a very large Classic ASP site that has recently had an error discovered. It reads and writes from an Access database multiple times, and all of that is working as intended. However, I believe there is an error in this part of the code:
Dim SeptAvg, mvUPreq, mvSeptAvg
SeptAvg = CDbl(rs.fields(5))
mvUPreq = -0.15
if SeptAvg <= mvUPreq then
mvSeptAvg = true
else
mvSeptAvg = false
end if
Now in this case, the SeptAvg in the access database is -8.5%. This expression should be evaluating to True - but it's not. Immediately after this code, there is an update to the Access database that sets the field (which is a checkbox in the Access database) to true or false. The checkbox is always left unchecked. I have checked and rechecked the database update code and I know there are no errors there. Is there something happening with the CDbl on the -8.5% value from the database?
Please advise, because I have very limited Classic ASP experience.
-8.5% = -0.085 and -0.085 is indeed larger than -0.15. This is why it is evaluating to true
-1 > -10
Abs(1) < Abs(10)
1 < 10
If you want it evaluated as TRUE, you need to tweak your code a little bit :
Dim SeptAvg, mvUPreq, mvSeptAvg
SeptAvg = CDbl(rs.fields(5))
mvUPreq = -0.15
if abs(SeptAvg) <= abs(mvUPreq) then
mvSeptAvg = true
else
mvSeptAvg = false
end if
-8.5% expressed as a decimal is -0.085
So the If condition is equivalent to ...
if -0.085 <= -0.15 then
But -0.085 is greater than -0.15, so the condition is not True, so mvSeptAvg does not get set to True.