[AccessD] AXP: Report/Subreport parameters

Charlotte Foust cfoust at infostatsystems.com
Wed Jul 30 11:15:31 CDT 2003


OW!!

Arthur, please note that Gustav is the one to address the withering
comments to.  I was not the sarcastic one. <g>

Charlotte Foust

-----Original Message-----
From: Gustav Brock [mailto:gustav at cactus.dk] 
Sent: Wednesday, July 30, 2003 8:05 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] AXP: Report/Subreport parameters


Hi Charlotte

Yeah, I too noticed the sloppiness from the hand of Mr. Static himself.
And if you initially fire those functions _without_ a parameter, they
return 1899-12-30 which may or may not be what you want; I would prefer
that a non-specified date would be today's date ... but that, of course,
depends.

So Arthur, is this your new style - writing junior code - or did you
experience a senior moment??? 

/gustav


> Arthur,

> Aren't *all* variables declared in a static function automatically 
> static?  I thought that was the point.  If you declare the function 
> without the static keyword, then only dCurrent would be static within 
> the function.  The end result would be the same.

> Charlotte Foust

> -----Original Message-----
> From: Arthur Fuller [mailto:artful at rogers.com]
> Sent: Wednesday, July 30, 2003 6:15 AM
> To: 'Access Developers discussion and problem solving'
> Subject: RE: [AccessD] AXP: Report/Subreport parameters


> 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

_______________________________________________
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