473,387 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to print user-entered parameters on a report?

sueb
379 256MB
I have several reports based on queries that require the user to enter a Start and End Date.

How do I access these parameters so I can print them on the report?
Feb 17 '11 #1

✓ answered by ADezii

  1. Let's assume that in your Query that is the Data Source for the Report, you have the following Parameter in the Criteria Row of the [Start Date] Field:
    Expand|Select|Wrap|Line Numbers
    1. [Enter Start Date]
  2. Create a Calculated Field in your Query that will retrieve the Value of the Parameter (must be an exact match), as in:
    Expand|Select|Wrap|Line Numbers
    1. sDate: [Enter Start Date]
  3. Position a Text Box to wherever you would like the Start Date Parameter to appear on your Report.
  4. Set the Control Source of the Text Box equal to the Calculated Field, as in:
    Expand|Select|Wrap|Line Numbers
    1. sDate
  5. Now, whatever Value the User enters for the Start Date Prompt will be reflected in the Calculated Field (sDate). By setting the Control Source of a Text Box to this Field, the entered Value will be displayed in the Report.
  6. Repeat the process for the End Date.
  7. Should you have any trouoble with this, I can Attach a very simple Demo to illustrate this point.

8 4271
ADezii
8,834 Expert 8TB
  1. Let's assume that in your Query that is the Data Source for the Report, you have the following Parameter in the Criteria Row of the [Start Date] Field:
    Expand|Select|Wrap|Line Numbers
    1. [Enter Start Date]
  2. Create a Calculated Field in your Query that will retrieve the Value of the Parameter (must be an exact match), as in:
    Expand|Select|Wrap|Line Numbers
    1. sDate: [Enter Start Date]
  3. Position a Text Box to wherever you would like the Start Date Parameter to appear on your Report.
  4. Set the Control Source of the Text Box equal to the Calculated Field, as in:
    Expand|Select|Wrap|Line Numbers
    1. sDate
  5. Now, whatever Value the User enters for the Start Date Prompt will be reflected in the Calculated Field (sDate). By setting the Control Source of a Text Box to this Field, the entered Value will be displayed in the Report.
  6. Repeat the process for the End Date.
  7. Should you have any trouoble with this, I can Attach a very simple Demo to illustrate this point.
Feb 17 '11 #2
NeoPa
32,556 Expert Mod 16PB
Sue, that really depends very much on how you specify to the report the date range it should reflect. That should be in the question.

For now though, I will deal with the most common way of handling filtering within a form or report, which is with the .Filter parameter (It's designed for just that purpose and makes filtering simpler).

In such a scenario, you should know how the filter string will present itself. I would guess at something like "[RptDate] Between #m/d/yyyy# AND #m/d/yyyy#".

From this point it is up to you to parse the string so that you retrieve the dates contained therein. For such as this I would use code (in Report_Open()) similar to :
Expand|Select|Wrap|Line Numbers
  1. Private datFrom As Date, datTo As Date
  2.  
  3. Private Sub Report_Open()
  4.     On Error Resume Next
  5.     datFrom = CDate(Split(.Filter, "#")(1))
  6.     datTo = CDate(Split(.Filter, "#")(3))
  7. End Sub
Feb 17 '11 #3
ADezii
8,834 Expert 8TB
@NeoPa: I don't think that you can use the Report's Filter Property in this manner, can you? Technically, it is not the Report that is being Filtered, and you will receive an Empty String for the Filter Property, instead of the actual Query Parameter(s). FilterOn would not automatically be set to ON under these conditions, would it?
Feb 17 '11 #4
NeoPa
32,556 Expert Mod 16PB
Yes you can ADezii. I have done (for a Form rather than a Report if I'm precise). This would not involve the use of a paramater query mind you, but rather a more straightforward, open, query where the filtering is expected to be applied externally. I'll illustrate the different concepts :

RecordSource
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM   [Table]
  3. WHERE  ([DateField] Between [Enter Start Date] And [Enter Finish Date])
Alternatively :

RecordSource
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM   [Table]
Filter
Expand|Select|Wrap|Line Numbers
  1. "([DateField] Between #m/d/yyyy# And #m/d/yyyy#)"
Notice how this keeps the static SQL (SELECT & FROM clauses) where they don't need to be changed, and the more variable part (WHERE clause or Filter) easily manipulable without having to fiddle with the RecordSource. As a developer, it also keeps the two elements separate, so one can concentrate more easily on the element one is dealing with at the time. I hope that makes sense.
Feb 17 '11 #5
ADezii
8,834 Expert 8TB
Thanks, my misinterpretation. I thought you were trying to extract the Filter Property in conjunction with the Parameter Query.
Feb 17 '11 #6
sueb
379 256MB
So I would put the "between" statement in my report's query, and the "report open" subroutine in my report's OnOpen property, and then I would be able to use (from your instance) "datFrom" and "datTo" as controls on my report?

I'm going to try that and post back what I found.

Thanks!
Feb 17 '11 #7
NeoPa
32,556 Expert Mod 16PB
Sue, in a case such as this, where two members offer differing solutions, it's better when replying, to make it clear whom you are replying to. In this case, reading between the lines, I expect you are responding to ADezii. Of course, it's always best to reply to all members who respond, even if only to say that you don't feel their suggestion suits you for some reason (even if it's as simple as that you don't really understand the suggestion), but that's down to you personally of course.

Conversations can get quite complicated though, if you don't at least make it clear to whom your message is directed.
Feb 18 '11 #8
ADezii
8,834 Expert 8TB
@sueb, I too am also not sure as to exactly whom you are addressing. Realizing that my approach may be a little confusing if you have never done it before, I decided to create a simple Demo to illustrate this point. I also demonstrated a second Method by which you can capture the actual Parameter Values via the Calculated Fields and assign them to a Label. This approach requires that you include both Calculated Fields in the Report, but make them invisible.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Activate()
  2.   Me![Label1].Caption = "Sales for Acme Manufacturing between " & _
  3.                          Me![SDate] & " and " & Me![EDate]
  4. End Sub
In any event, both approaches are represented in the Attachment. Click on the Command Button, and when prompted for a Start and End Dates enter 3/1/2011 and 3/31/2011 respectively. This is for effect only. Keep in mind that you also have NeoPa's approach which now gives you three ways to accomplish what you have requested. Any questions, feel free to ask.
Attached Files
File Type: zip Parameters.zip (20.5 KB, 120 views)
Feb 18 '11 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Leonardo | last post by:
I have the following associative array: $user=1; $user=1; $user=0; $user=1; $user=0; $user=1; $user=1;
21
by: Steel | last post by:
Hi at all, I have a very long html page with many photo. Therefore the best to print this page is to print the some page as PDF. Therefore I maked a PDF file like my page to print best. I'ld want...
5
by: Alan | last post by:
While not rs.eof <td><%=rs("InvoiceNo")%></td> <td><%=rs("Name")%></td> <td><a href="InvoicePrint.asp?WInv=<%=rs("InvoiceNo")%>"></a></td> <td>Print this invoice</td> rs.MoveNext Wend Now...
4
by: rom | last post by:
I need to print a html table when the user clicks on a key. the problem is that i don't want the printer dialog box to appear. i guess this is impossible in javascript so i think to create an...
3
by: James J. Besemer | last post by:
I would like to champion a proposed enhancement to Python. I describe the basic idea below, in order to gage community interest. Right now, it's only an idea, and I'm sure there's room for...
7
by: hlubenow | last post by:
Hi, recently there was a thread about hiding the python-script from the user. The OP could use http://freshmeat.net/projects/pyobfuscate/ H.
9
by: =?Utf-8?B?Sm9obiBBdXN0aW4=?= | last post by:
I have an app that prints entry tickets. If the printer driver is not set up exactly to detect the black mark on the back of the ticket, the tickets do not print correctly. Because of this, all...
1
by: =?Utf-8?B?aGZkZXY=?= | last post by:
Hello, I have a web application that makes use of the SQL Membership and Role providers. My app has admin screens to manage users (membership), roles, and supplementary user data. I have just...
1
by: ukbasak | last post by:
Hi, I tried to print user name who ever accesss application. I added the code request.getHostName() and request.getRemoteAddr(). The get.getRemoteAddr() is showing IP address but the code...
9
by: happyse27 | last post by:
Hi All, In perl script(item b below) where we check if html registration form are filled in properly without blank with the necessary fields, how to prompt users that the field are incomplete...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.