[AccessD] dim question

pedro at plex.nl pedro at plex.nl
Fri Jul 30 11:35:14 CDT 2004


Hello Group,

Why do i get different results with the function below when placing dim inside and outside the function.

<code>

Option Compare Database

Dim strLastPnr As String
Dim lngPnrCount As Long

Function NumberRecs(strPnr As String) As Long

If strPnr <> strLastPnr Then
lngPnrCount = 1
strLastPnr = strPnr
NumberRecs = 1
Else
lngPnrCount = lngPnrCount + 1
NumberRecs = lngPnrCount
End If

End Function


<code>

as result i get

Pnr      field       Exp1
0001      t1          1
0001      t2          2
0001      t3          3
0005      t1          1
0006      t1          1




<code>

Option Compare Database

Function NumberRecs(strPnr As String) As Long

Dim strLastPnr As String
Dim lngPnrCount As Long


If strPnr <> strLastPnr Then
lngPnrCount = 1
strLastPnr = strPnr
NumberRecs = 1
Else
lngPnrCount = lngPnrCount + 1
NumberRecs = lngPnrCount
End If

End Function


<code>

as result i get

Pnr      field       Exp1
0001      t1          1
0001      t2          1
0001      t3          1
0005      t1          1
0006      t1          1



TIA

Pedro Janssen




More information about the AccessD mailing list