473,668 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to print user-entered parameters on a report?

sueb
379 Contributor
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
8 4286
ADezii
8,834 Recognized Expert Expert
  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,568 Recognized Expert Moderator MVP
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 Recognized Expert Expert
@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,568 Recognized Expert Moderator MVP
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 Recognized Expert Expert
Thanks, my misinterpretati on. I thought you were trying to extract the Filter Property in conjunction with the Parameter Query.
Feb 17 '11 #6
sueb
379 Contributor
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,568 Recognized Expert Moderator MVP
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 Recognized Expert Expert
@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
18877
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
5725
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 that when the user press the print button in the browser , it print automatically the pdf file and not the html page. To do that I insert at the top of my page: <link media="print" rel="alternate" href="printthepage.pdf"> But it do not work and...
5
3646
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 user needs to click the link to open the invoice, and then select File--Print from the menu to print it out, and then return back to print
4
2357
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 event that will be fired by a keyup event, this event will submit the page, and i will be able to print in from the vb.net without the printing dialog box. the problem is that on the server i can't print the web table because i already submitted that...
3
2105
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 improvement. And of course it's possible there's some serious "gotcha" I've overlooked. Thus I welcome any and all comments. If there's some agreement that this proposal is worth further consideration then I'll re-submit a formal document in...
7
2976
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
2363
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 users are logging on with the same user name to ensure they get a correctly configured printer driver. The application runs on a Terminal Server via the RDP client. In order to audit the actions of users, it is necessary to identify each user....
1
2940
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 deployed the application to a production server. My Question: How do I create the initial Admin role and user in the clean/unpopulated database that has the Membership and Role schema on this production server?
1
4005
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 request.getHostName() should show the host name but it also show the ip address also. please give me any solution so that client machine name can be found. Thanks in advance....
9
4240
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 or blank and then go back to main page(item a below user registration html page) always, something like goggle or msn login page function... Thanks and Best Rgds, Andrew a) script called from user registration html...
0
8462
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8381
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8893
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8799
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
5681
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2026
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1786
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.