Discussion Locked

ADO programming need

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I try to add newrecord that have a autonumbering field so when I do update I can't take the value of autonumbering fields
so how can i know the value of autonumbering of newrecord without closing the recordset
thanks

5 replies

by john_wills

Dim AutoCatcher As String
Dim AutoHolder As DAO.Recordset
AutoCatcher = "Select max(autothing) as Indifferent from TableWithAutonumbering;"
Set AutoHolder = CurrentDb().OpenRecordset(AutoCatcher)
AutoHolder.MoveFirst
Me.AutoThing = AutoHolder.Fields(0)
This means using a new recordset, which may be possible in your circumstances. But perhaps you can do something with the recordset you already have.

by khalid

if I write this code
-------
adoprimaryRS.addnew
adoprimaryRS.fields("Name")="Jon"
adoprimaryRS.update
-------
so if I have a autonumbering Fields (ID) in that same table
and after updating I want that value it saved in the (ID) field
--
I hope you understand me

by john_wills

Perhaps I'm being dense - I haven't had my third cup of tea yet - but it sems to me that what I wrote before is much what you want: just call ID what I call autothing, and set the string once only, somewhere above.

This discussion is closed to new replies.