How can I display a number from a report - ms-access

I'm trying to display a number which is generated each time on a report and have it displayed each time it's updated into a Form page

You can refer to reports like you do with forms. There is a Reports-Collection, like the Forms-Collection and a report has a Controls-Collection like a form.
Reports.Item("MyReportName").Controls.Item("ControlNameOnReport")
or the short bang version:
Reports!MyReportName!ControlNameOnReport
But you should extract the generation of the value to a public function and call that function if necessary.

Related

SSRS: calculation with input

I am new in SSRS and I would like to know if it is possible in SSRS to create blank fields in which you can enter values and this values should calculated with a value in the implemented query. Something like this here.
And if this is possible how can I do something like this? With Parameter?
The only input the user can make to a report is via parameters
In the report itself you cannot use SSRS to create input fields. The only way to input data would be to use parameters in the toolbar and pass through the data through that way, with your output appearing in the rendered report
Here is an example of parameters inside a report. For example, you can use a date if you want the data of a certain day. In your case you'll need an int box and enter the value in there.

Access 2010 - Report asks to enter parameter value

I have a report with a subreport. Report is unbound (it is used as a template for letter and contains plain text only). Values in the subreport are based on values of two combo boxes located in a form.
So the logic is as follows - when the form (frmForReport) is loaded the user selects values in combo boxes intended to filter the database (cboSelectCompany and cboSelectPU), then clicks OK button which opens my report with its subreport. Subreport is populated from a query where two of fields have those combo boxes as criteria. Everything works fine (I select what I need in combo boxes, report opens in Report View with the subreport showing all filtered records without any warnings or requests) until I want to switch to Print Preview or Create PDF. Every time when I do so I see pop-up window Enter Parameter Value with a reference to one of criteria used in the subreport. When I close this window I can proceed further, save it as pdf or switch to Report View but the subreport appears blank, literary disappears.
This is for Access 2010. Below is the query used as a record source for the subreport:
SELECT qryForLetter.CrossingID, qryForLetter.DispID, qryForLetter.AgreType, qryForLetter.Legal
FROM qryForLetter
WHERE (((qryForLetter.Company)=[Forms]![frmForReport]![cboSelectCompany]) AND ((qryForLetter.PU)=[Forms]![frmForReport]![cboSelectPU]));
What do I miss? How do I get rid of this pop-up window? Any help is greatly appreciated.
You could try replacing parameters [Forms]![frmForReport]![cboSelectCompany]) and [Forms]![frmForReport]![cboSelectPU] with functions.
Create global variables in the header of a module:
Public Company As ...
Public PU As ...
... replacing the ellipses ... with the correct datatype.
In your Combo Boxes' AfterUpdate events, assign the value associated with the Combo to the appropriate global variable, e.g.:
Company = cboSelectCompany
and
PU = cboSelectPU
and create functions (again replacing the ellipses ... with the correct datatype):
Public Function fnCompany() As ...
fnCompany = Company
End Function
Public Function fnPU() As ...
fnPU= PU
End Function
Then change the data source to:
SELECT qryForLetter.CrossingID, qryForLetter.DispID, qryForLetter.AgreType, qryForLetter.Legal
FROM qryForLetter
WHERE (((qryForLetter.Company)=fnCompany()) AND ((qryForLetter.PU)=fnPU()));
This has the effect of removing the dependence of the report from the form fields, which appears to be the issue.

Access report prints multiple pages when text box control source is using a multi-value field from a table

The Access 2010 report i have has a text box that uses a multi-value field from a table for its control source. I know multi-value fields in tables are bad but its what i have to work with at the moment.
The problem i am having is that even though its only a two page report when i physically print it or do a print preview i get more then 2 pages. So if the multi-value field has (2) values i will get (4) pages total with the same information basically (2) copies.
How can i prevent the report from printing a copy for each value?
Ok so I will answer my own question now that i have found a work around.
I found a work around that will let me print only the pages i want (ie the first two pages or one copy not several)
In my macro instead of using RunMenuCommand PrintObject that just prints the report.
I created a vba function
Function cmdPrint()
DoCmd.PrintOut acPages, 1, 2 //acPages, start_page, end_page
End Function
and used this function from the macro using RunCode cmdPrint()
Now I only get one copy not several. Like I said its a work around but it works for me and i hope that it will help someone else someday with the same problem.

How to collect input via a form and pass to report query in Access

I have an Access 2003 MDB where I would like to present a small form for the user to input two parameters "Start Date" and "End Date". Thanks to another Stack Overflow user ("Kevin Ross"), I learned how to embed the form control directly in the query that is used by the report I would like to display.
SELECT q1.CasesAssigned, q2.WarningsIssued
FROM
(SELECT COUNT(*) AS CasesAssigned
FROM vwCaseDetail
WHERE DateAssigned Between [Forms]![frmReporting]![txtStartDate]
AND [Forms]![frmReporting]![txtEndDate]) as q1,
(SELECT COUNT(*) AS WarningsIssued
FROM vwWarningDetail
WHERE DateIssued Between [Forms]![frmReporting]![txtStartDate]
AND [Forms]![frmReporting]![txtEndDate]) as q2
I have tried two different ways to open the report and pass the users input:
After the user enters parameters I call DoCmd.OpenReport "myReport", acViewPreview. The problem here is that the reports opens and close so fast I never even see it. Ideally I would like to close the input collection form and then open the report.
Inside the Report_Open event I have code that opens the form that collect the users input. The input collection form opens, however I still get prompted by the report to enter in the two parameters. The report does not seem to be gathering the parameters from the input collection form.
Any suggestions on the proper way to pass data collected on a form to a report? Thank you.
Well,
The problem should be the logic of what your wantig. Why do you want a report calling a form? Why not a form in wich you fulfill the parameters then call the report?
You can perform your requisites in this way:
Create a form containing the fields corresponding to your desired parameters (Eg two textboxes called Param1 and Param2, in a form called Form1)
Create a query that retrieves the data for your report, referencing, in the conditions field, the parameters in the form (In the example, [Forms]![Form1]![Param1] and [Forms]![Form1]![Param2]). Also, right clik on a empty space of query builder and select "parameters". Inform all the parameters (with the entire strings [Forms]![Form1]![Param1] and [Forms]![Form1]![Param2]) with the correct data type. Let's call this query Query1
Create a report based on Query1. Lets call this report as Report1
Back to Form1, create a button (use the Wizard, its faster) for calling Report1.
Execute the Form1, in runtime fill the textboxes with the desired parameters then click the button. Make sure that you have data in your tables wich corresponds the Query.
In the other parts of your application, instead you call Report1 directly, call the Form1 that will manage Report1 querying and showing.

How to reference in SSRS report (in client mode) objects from application

I have a report created in SSRS in client mode, which is run disconnected: I create the data source in code and pass to the report as a DataView. It works ok.
But I need to be able to reference from the project to some objects (variables, whatever) from my application, as follows:
I need some totals that are not calculated based on data in report. e.g. the reports show total sales in a period, with own total, but I need to display a field in report footer - previous month total (actually they are about 10 other "previous" totals).
I need to have some columns show / hide based on some settings in the application (e.g. I have application option : Show Previous month sales)
Any thoughts on how to do this?
Thank you
Q1-> In order to use data in your reports, you need to specify the data inside of a Datasource object. You cannot simply use the variables if that is what your intentions were. So yes, you are doing this the right way. *** Sorry, you could theoretically used Report Parameters for this.
Q2-> This is the real reason to use Report Parameters. You can pass parameters to the report to do exactly this. If the HideColumn parameter (for example) is set to true, you could hide all the columns that need to be hidden.
http://msdn.microsoft.com/en-us/library/ms251750%28VS.80%29.aspx
For question 1 - the data - the easiest approach would be to create a DataTable in memory and add it as another dataset OR to add fields for your original dataview that contain these values.
Question 2 - To hide or show the columns based on settings make the column visibility an expression based on the value of a parameter, in your code behind set the parameter value to your application setting.