[AccessD] Query Line Numbers

Erwin Craps - IT Helps Erwin.Craps at ithelps.be
Tue Mar 29 08:28:02 CST 2005


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



More information about the AccessD mailing list