Microsoft Access
--
Questions
--
Followers
Top Experts
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
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
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
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
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






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
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.