[AccessD] AXP: Report/Subreport parameters

Arthur Fuller artful at rogers.com
Wed Jul 30 09:15:11 CDT 2003


Yet another case for static functions! You could create a pair of static
functions called, say, DateRangeBegin() and DateRangeEnd() and then modify
your subforms' recordsource queries to refer to the static functions rather
than accepting parameters. IOW:

SELECT * FROM someTables WHERE DateColumn BETWEEN DateRangeBegin() AND
DateRangeEnd();

Here are the functions:

<code>
Static Function DateRangeBegin(Optional dNew As Date) As Date
    Static dCurrent
    Dim dTemp As Date   'defaults to 12/30/99
    If dNew <> dTemp Then dCurrent = dNew
    DateRangeBegin = dCurrent
End Function

Static Function DateRangeEnd(Optional dNew As Date) As Date
    Static dCurrent
    Dim dTemp As Date
    If dNew <> dTemp Then dCurrent = dNew
    DateRangeEnd = dCurrent
End Function

</code>

To use them, you call them passing a variable (which might come from a form
that has the date-time picker on it, or simply requests dates):

DateRangeBegin( myControl )
DateRangeEnd( myControl )

To retrieve the values, you call the functions without a parameter:

DateRangeBegin()
DateRangeEnd()

That's it. Nothing to it, once you understand the concept. And the really
cool part about this approach is that you're not tied to any specific form
etc. So your queries don't need parameters or anything; they can simply
refer to the functions and you get what you want. For example, having copied
the functions into a module, you can do this from the debug window:

? daterangebegin(now())
30/07/2003 10:14:12 AM 
? daterangebegin()
30/07/2003 10:14:12 AM 

Hth,
Arthur

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Donna Martin
Sent: July 30, 2003 8:33 AM
To: Access Gurus
Subject: [AccessD] AXP: Report/Subreport parameters


Good morning,

This is a dumb question, but I'm having difficulty finding the answer this
morning...

Have a main report w/multiple subreports.  Two of the subreports have date
parameters that have to be entered before display.  The report works;
however, I have to enter the dates multiple times, and for each page.

I should know the answer to this, but have been working long hours for the
last several months.  My brain is tired...

Can someone please help?

Thanks much.

Donna Martin

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list