I am hoping someone can help me out...
Maybe I am being stupid...
Trying to get the autonumber on an ADO ADDNEW. And I been going around and around and I am starting to get phsyically ill from the dizziness
So now I am working with a simple example meaning nothing else is in the ACCESS file. I created a simple form with a button to run the code below and I still can't get it to work.
The Connection String is Accessing a SQL Server 2000 database
The inserting of the new record does work and show up in the table.
MsgBox rst.Fields("orderindex") Return NOTHING
rst.Open "Select ID=@@Identity", con RETURNS the Actual Number
AND if I use this Provider=Microsoft.Access.OLEDB.10.0 as the provider then MsgBox rst.Fields("orderindex") statement all of a sudden returns the number
I am worried using the select ID=@@identity is a clouge and may not always work right. A clouge more becuase it is combined with the ADDNEW instead of a traditional INSERT into SQL Statement.
Now isn't a sqloledb as provider SUPPOSE to return the autonumber when using the ADDNEW and UPDATE together?
I have even tried putting the msgbox before the Update to see if that would get it and it doesn't.
I really DO NOT want to do an insert statement as I have between 10-15 fields in each of the 5 tables that need to be inserted into. And the record size is NOT over 64kb.
And I do not want to use that funky provider as I am developing in ACCESS 2003 with file format of 2000 because my end client is using 2002
Any Help would be so tremendously appreciated. I been going around with this for I say about 16 hours of coding trying and trying to figure out what is up.
Many Thanks!
Angela
Maybe I am being stupid...
Trying to get the autonumber on an ADO ADDNEW. And I been going around and around and I am starting to get phsyically ill from the dizziness
So now I am working with a simple example meaning nothing else is in the ACCESS file. I created a simple form with a button to run the code below and I still can't get it to work.
The Connection String is Accessing a SQL Server 2000 database
Code:
Dim con As New ADODB.Connection
Dim rst As New ADODB.Recordset
con.Open CONNECTSTR
rst.Open "torders", con, adOpenDynamic, adLockOptimistic
rst.AddNew
rst.Fields("orderclientID") = 1
rst.Update
MsgBox rst.Fields("orderindex")
rst.Close
rst.Open "Select ID=@@Identity", con
MsgBox rst.Fields("ID").Value
The inserting of the new record does work and show up in the table.
MsgBox rst.Fields("orderindex") Return NOTHING
rst.Open "Select ID=@@Identity", con RETURNS the Actual Number
AND if I use this Provider=Microsoft.Access.OLEDB.10.0 as the provider then MsgBox rst.Fields("orderindex") statement all of a sudden returns the number
I am worried using the select ID=@@identity is a clouge and may not always work right. A clouge more becuase it is combined with the ADDNEW instead of a traditional INSERT into SQL Statement.
Now isn't a sqloledb as provider SUPPOSE to return the autonumber when using the ADDNEW and UPDATE together?
I have even tried putting the msgbox before the Update to see if that would get it and it doesn't.
I really DO NOT want to do an insert statement as I have between 10-15 fields in each of the 5 tables that need to be inserted into. And the record size is NOT over 64kb.
And I do not want to use that funky provider as I am developing in ACCESS 2003 with file format of 2000 because my end client is using 2002
Any Help would be so tremendously appreciated. I been going around with this for I say about 16 hours of coding trying and trying to figure out what is up.
Many Thanks!
Angela