Does DataSISPEDA.Recordset.Fields("DocID").Value only contain whole numbers? If it does, the most sensible thing to do would be convert the field in the database to a Long datatype.
That way you avoid all the overhead of using Trim (which is very slow) and Val which actually returns a Double.
Then you would declare max as a Long and your code would look likeVB Code:
Do While Not DataSISPEDA.Recordset.EOF If max <= DataSISPEDA.Recordset.Fields("DocID").Value Then max = DataSISPEDA.Recordset.Fields("DocID").Value DataSISPEDA.Recordset.MoveNext Else DataSISPEDA.Recordset.MoveNext End If Loop




Reply With Quote