[AccessD] Query Line Numbers

Heenan, Lambert Lambert.Heenan at AIG.com
Wed Mar 30 12:44:19 CST 2005


If Access sees a function call in a query, and there is no query field
involved as a parameter to the function, Access 'optimizes' things by
calling the function just once when the query is run. When there is a field
used as a parameter to the function Access assumes something is being done
with the field in the function, and so calls the function once for every
record returned by the query.

HTH

Lambert


> -----Original Message-----
> From:	accessd-bounces at databaseadvisors.com
> [SMTP:accessd-bounces at databaseadvisors.com] On Behalf Of Lonnie Johnson
> Sent:	Wednesday, March 30, 2005 12:21 PM
> To:	Access Developers discussion and problem solving
> Subject:	RE: [AccessD] Query Line Numbers
> 
> That's cool. I love it. How does putting a field into the function make it
> work? Just curious.
> 
> Erwin Craps - IT Helps <Erwin.Craps at ithelps.be> wrote:Code below will do
> the tric
> 
> You use this function in a query but mus give a field (any field) in the
> parameters to trick access.
> 
> The function presumes that the query takes less then 10 seconds.
> When using from vba i'ts safer to first first use the reset parameter
> before using the function.
> It stores a static variable that is reset by the reset command or by a
> 10second timeout.
> 
> Greetz
> 
> 
> 
> Function HitCounter(varDummy As Variant, Optional blnReset As Boolean)
> As Long
> ' Comments :
> ' Parameters: pvarDummy
> ' pfBlnReset -
> ' Returns : Long -
> ' Modified :
> '
> ' --------------------------------------------------
> 'TVCodeTools ErrorEnablerStart
> On Error GoTo PROC_ERR
> 'TVCodeTools ErrorEnablerEnd
> 
> Static lngHitCounter As Long
> Static dteLastRun As Date
> 
> 
> If blnReset = True Then
> lngHitCounter = 0
> Exit Function
> End If
> 
> If DateDiff("s", dteLastRun, Now()) > 10 Then
> lngHitCounter = 0
> End If
> 
> lngHitCounter = lngHitCounter + 1
> HitCounter = lngHitCounter
> dteLastRun = Now()
> 
> 
> 'TVCodeTools ErrorHandlerStart
> PROC_EXIT:
> Exit Function
> 
> PROC_ERR:
> Select Case Err
> Case Else
> MsgBox Err.Description
> Resume PROC_EXIT
> End Select
> 'TVCodeTools ErrorHandlerEnd
> 
> End Function 
> 
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Keith
> Williamson
> Sent: Tuesday, March 29, 2005 4:11 PM
> To: 'Access Developers discussion and problem solving'
> Subject: [AccessD] Query Line Numbers
> 
> This may be an extremely simple thing...and I am just being stupid,
> but.....is there a way (within a query) to setup an expression that
> numbers the lines? I can do this simply enough in a report.....but
> can't think of a way to do this in a query. The reason is I am doing a
> routine that transfers text to a deliminated text file. This needs to
> be based on a table or query. I am trying to base this on a query, but
> need a line number. I can't figure out how to do this within the query.
> 
> Thanks for any help.
> 
> Regards,
> 
> Keith E. Williamson
> Ashland Equipment, Inc
> phone # (410) 273-1856
> fax # (410) 273-1859
> 
> 
> 
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 
> 
> 
> 
> May God bless you beyond your imagination!
> Lonnie Johnson
> ProDev, Professional Development of MS Access Databases
> Visit me at ==> http://www.prodev.us
> 
> 
> 
> 
> 
>  
> 
> 
> 
> 
> 
> 		
> ---------------------------------
> Do you Yahoo!?
>  Take Yahoo! Mail with you! Get it on your mobile phone.
> -- 
> 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