Link to home
Start Free TrialLog in
Avatar of VGuerra67
VGuerra67

asked on

need to get the last record of a table

I have a client table where i assign client numbers.  I would like to go to the last record and add one to the client numbers.  
This is my code.

 Set db = CurrentDb
        Set rs = db.OpenRecordset("SELECT RIGACCT FROM ClientInfo")
        rs.MoveLast
        'rs.Move -1
        'Debug.Print rs("rigacct")
        BacctNum = rs!RIGAcct
        AcctNum = BacctNum + 1
        Me.RIGAcct = AcctNum
        'Me.Requery

It stopped working for me. it gets stuck on the Set rs.  The error message that i get is in valid type.

Any help would be appreciated
ASKER CERTIFIED SOLUTION
Avatar of Fabrice Lambert
Fabrice Lambert
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of VGuerra67
VGuerra67

ASKER

thank you
HI,

I think instead of iteratiing the resultset till the end, you can use a simple  query like
    SELECT TOP 1 RIGACCT + 1 FROM ClientInfo ORDER BY ID DESC
   where, Id is the unique auto generating column of the table