Pedro Janssen
pedro at plex.nl
Fri Jul 30 07:47:41 CDT 2004
Hello Andy, Thanks for your help. Sometimes answers look so simple! Pedro ----- Original Message ----- From: "Andy Lacey" <andy at minstersystems.co.uk> To: "Access Developers discussion and problem solving" <accessd at databaseadvisors.com> Sent: Friday, July 30, 2004 12:39 PM Subject: Re: [AccessD] dim question > Pedro > Not such a dim question I didn't think ;-) > With the dim outside the function it doesn't get reinitialised for each > call, so when you're adding to it it's starting from a value. You'd need to > put: > > lngPnrCount=0 > > at the top of the function. > > -- > Andy Lacey > http://www.minstersystems.co.uk > > > > --------- Original Message -------- > From: Access Developers discussion and problem solving > <accessd at databaseadvisors.com> > To: AccessD at databaseadvisors.com <AccessD at databaseadvisors.com> > Subject: [AccessD] dim question > Date: 30/07/04 09:36 > > > > > 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 > > > > -- > > _______________________________________________ > > AccessD mailing list > > AccessD at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/accessd > > Website: http://www.databaseadvisors.com > > > > > > > > > > > > ________________________________________________ > Message sent using UebiMiau 2.7.2 > > -- > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > >