Sorry let me explain.
Your problem is that your performing 2 actions an insert then a select. As you have correctly identified it is not impossible for a second insert to happen b4 the 1st select returns the ID. What I'm suggesting is you create a recordset with a select statement and use the .AddNew method instead of using SQL INSERT. Whats great about this is it facilitated using the same page for both adding new records and editing existing records. I will try and demonstrate with some code.
<%
' Check to see if in edit mode
Dim MyID : MyID = -1
If Request.QueryString("ID") <> "" Then MyID = Request.QueryString("ID")
Dim strSQL : strSQL= "Select ID, field1, etc FROM tblName WHERE ID = "& MyID
Set rs_MyRS = Server.CreateObject("ADODB.Recordset")
rs_MyRS.ActiveConnection = connStr ' Set your connection string
rs_MyRS.CursorType = 1
rs_MyRS.CursorLocation = 2
rs_MyRS.LockType = 2
rs_MyRS.Source = strSQL
rs_MyRS.Open()
' If there was no querystring then the record set will be end of file so we create a new record
If rs_MyRS.EOF Then rs_MyRS.AddNew
' Then you set the new values
rs_MyRS("field1") = "SomeValue"
' You then update the database
rs_MyRS.Update
' Job Done
' To return the ID of the new record you can use the recordset
Dim MyNewID
MyNewID = rs_MyRS("ID")
' Be careful you will need the correct cursors for your DB provider for this to happen - the above should be OK
' Cleanup
rs_MyRS.Close
Set rs_MyRS = Nothing
%>
Using this method INSERTS are a little slower but you can retrieve the new ID in 1 action and you can merge your edit code into your add page (if needed)
I hope this a a little clearer
Courtenay Probert
http://www.probert.me.uk