how to create a counter

  • Thread starter Thread starter paul
  • Start date Start date
P

paul

Hi,
I have an Access 2000 application with a dozen of users.
My application required a counter for each report, 2004-
001,2004-002...., by reference Knowledge base, I created a
separate table with one field and one record, and use VB
code to open this counter and retrieve. But since the
network is slow, the user sometime lost patience, and they
kill the process and crash the system. Any better way to
handle the counter problems?
Thanks for your kindly input.
 
Paul,

I assume you're using DLookup to get the next number. If the users get bored
waiting for the number to come back, then you have some serious network
problems. Despite the fact that DLookup is inherently slow - it's not *that*
slow! Try using this method instead:

Dim db As Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT ReportNumber FROM tblMyTable",
dbOpenForwardOnly)
If rs.AbsolutePosition > -1 Then
MsgBox "The next number is: " & rs!ReportNumber + 1
Else
MsgBox "The next number is: 1"
End If

rs.Close
Set rs = Nothing
Set db = Nothing

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Back
Top