Link to home
Create AccountLog in
Microsoft Access

Microsoft Access

--

Questions

--

Followers

Top Experts

Avatar of VGuerra67
VGuerra67

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

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


ASKER CERTIFIED SOLUTION
Avatar of Fabrice LambertFabrice Lambert🇫🇷

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Avatar of VGuerra67VGuerra67

ASKER

thank you

Avatar of Remya 6488Remya 6488🇮🇳

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

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.

Microsoft Access

Microsoft Access

--

Questions

--

Followers

Top Experts

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.