INSERT INTO to return ID

GUIDO22

Registered User.
Local time
Today, 19:44
Joined
Nov 2, 2003
Messages
515
In SQL Server :- when using INSERT INTO... the ID of the new record is returned . Is there a command in VBA to do the same?

I am using an SQL string as a parameter to Database_obj.Execute()

Any ideas please?
 
I am having the same problem?

Help Please
 
That is, as far as I know, a server thing. If the db you are using supports it(like MS SQL) then it should work just through the connection execute command, otherwise theres no 'safe' way of performing it.

An unsafe way(perfectly fine if the db only has one or two users, not suitable for large scale concurrant access) is to do something like the following(assuming the id is an autonumber or similar)

INSERT record

SELECT MAX(id) FROM table

and the id field will then be the last entry.
 
Have just assiged a date/time field to the record and select the record by this
 

Users who are viewing this thread

Back
Top Bottom