• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

Recordset

Beginner:
In Vb code,
how do you automatically add one number to the last recordset of Visdata.
I have:
Dim ID as integer
adolist.recordset.addnew
ID = lastID + 1
0
lxguz
Asked:
lxguz
1 Solution
 
bhagyeshtCommented:
fire a query as "select max(ID)+1 from <tableName>"
get the value and use the value in your code

Dim RS as RecordSet
Set RS=Con.execute("select max(ID)+1 from myTableName")
If RS.EOF then
  mynewID=1
else
  RS.moveFirst
  mynewID=RS(0).value
End if

then use myNewID

Second option is use a autonumber field
0
 
CleanupPingCommented:
lxguz:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now