Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Dates to a Report - Best Method

Status
Not open for further replies.

Maquis

Programmer
Jul 19, 2001
934
US
Hi there. I'm hoping someone can tell me what would be the best way to accomplish this.

I have a report which needs to display a date range in it's header. The problem is that this report will be called from several different forms. (It will never be opened directly from the database window). On some of the forms, the user will type in the begin and end dates in textboxes, but on other forms the app will calculate the dates behind the scenes.

I have several ideas for getting the dates to the report, but I'm not sure which ones would be considered "good programming practice" Any advice?

1. Store the dates in global variables and reference the variable in the on_open event of the report. (Global variables ICK [thumbsdown])

2. Pass the dates to the report as arguments. Ok, I admit, I don't know how to do this, but I read somewhere that it was possible)

3. Set the tag property of the report = dates and set the textbox = me.tag?

TIA

Maq [americanflag]
<insert witty signature here>
 
Hi,
This is a sticky situation, since you indicated that this report is run from several different forms. If this report was only run from one report, then it would be very simple to add a text box to the page header, and set its' control source to the form value, e.g., =[Forms]![frm???]![txtDate1]

Because the report is run from multiple locations, my advice is that the global variable may be the BEST and easiest solution.

I wrote an FAQ on how to pass criteria to a report via &quot;filter&quot;, but it has an inherent disadvantage in your case. For instance, if you pass 01/01/2003 and 01/31/2003, you may not have any records displayed for 01/01, and consequently, this date will not appear in the page header. Do you see the problem? Anyway, here is my FAQ on the topic: faq703-2657

There is some other code that can be written in the Open event of the report, but it might get a bit more complicated. In that, you would find all the open forms and see if one of your forms is running that provides the criteria of the date range. Part of this problem is that a user may have more than one of these forms open, so your code will need to check for this condition. Do you see this problem?

So, in the final analysis, the global variable may be the best solution. HTH, [pc2]
Randy Smith
California Teachers Association
 
Thanks for the reply.

I was originally going to use the me.tag method, but it didn't pan out very well. I've since discovered the need to actually query using these dates in several different spots, so I'm going to use global variables.

I've had the concept drilled into me over the past few years that Global variables are evil [snake] and should be avoided at all costs, so that's why I've been reluctant to use them much. (But sometimes they are just so darn useful!)

I really never thought about finding the Min and Max dates in the data and using those. Like you said, my data will rarely (if ever) have data on the begin and end dates so that really wouldn't help me much. The form open method was considered briefly, but my users will probably have both forms in question open so that won't help much either.

Maq [americanflag]
<insert witty signature here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top