Number of certain records problem... 
Author Message
 Number of certain records problem...

Hi.

    A strange thing happened. A recordset.Count property showed 6 records
(this is true number of records). When I try to find out how many records
(must be 6 or less) have a certain ID with following code, I got message
"OVERFLOW". Where is mistake?

UkPost=0
rstNPost.MoveFirst
While Not rstNPost.EOF
    If rstNPost!MatrFamID = Br Then
        UkPost = UkPost + 1
    Else
        rstNPost.MoveNext
    End If
Wend

rstNPost           is recordset connected with table with 6 records,
UkPost             is counter of records which satisfy condition
rstNPost!MatrFamID=Br.

Thanks in advance,
    Dejan Stosic.



Thu, 08 May 2003 03:00:00 GMT  
 Number of certain records problem...
You never move on if the record matches.  You keep recounting it.  Move
to MoveNext outside the If statement.

 While Not rstNPost.EOF
     If rstNPost!MatrFamID = Br Then
         UkPost = UkPost + 1
     End If
         rstNPost.MoveNext
 Wend

Quote:

> Hi.

>     A strange thing happened. A recordset.Count property showed 6 records
> (this is true number of records). When I try to find out how many records
> (must be 6 or less) have a certain ID with following code, I got message
> "OVERFLOW". Where is mistake?

> UkPost=0
> rstNPost.MoveFirst
> While Not rstNPost.EOF
>     If rstNPost!MatrFamID = Br Then
>         UkPost = UkPost + 1
>     Else
>         rstNPost.MoveNext
>     End If
> Wend

> rstNPost           is recordset connected with table with 6 records,
> UkPost             is counter of records which satisfy condition
> rstNPost!MatrFamID=Br.

> Thanks in advance,
>     Dejan Stosic.



Thu, 08 May 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Coding Problem with Record Numbers

2. Problem with number of records

3. How to create a certain number of buttons / labels

4. Problem getting Unique Numbers from a shared Record Type

5. Problem getting Unique Numbers from a shared Record Type

6. Breaking a field using textstream at certain column number (73)

7. how to make an autonumber field starting from a certain number

8. Problem with number of records

9. Problem with number of records

10. HOW DO I GROUP AND SUM CERTAIN RECORDS IN A SUBFORM

11. Duplicating labels for certain records in a report

12. Color text for certain records through VBA

 

 
Powered by phpBB® Forum Software