dblayout
|
| Posted: 07/22/2003, 2:57 PM |
|
I have an Orders table. 1 of the fields (order_number) is an Auto-Number field in an Access database. When I add a record to this table, it gets incremented perfectly but I need to know what that number was back in my program so I can add it to a receipt. How can I get that # after the record has been inserted? Again, this is an Access database.
Thanks
Chris
|
|
|
 |
rrodgers
|
| Posted: 07/22/2003, 4:22 PM |
|
In the
Grid AfterExecuteInsert event.
Dim NewIdent , rsIdent
Set rsIdent = DBConnectionName.Execute("SELECT @@IDENTITY As intIdent")
If Not rsIdent.EOF Then
NewIdent = CCGetValue(rsIdent,"intIdent")
End IF
Set rsIdent = Nothing
rob
|
|
|
 |
dblayout
|
| Posted: 07/22/2003, 7:24 PM |
|
Do I actually use the string "@@IDENTITY "?
Thanks for the help. I look forward to trying it out.
|
|
|
 |
rrodgers
|
| Posted: 07/22/2003, 8:31 PM |
|
On mssql. I am fairly sure it is a ANSI SQL standard. So I think it will work on access.
http://msdn.microsoft.com/library/default.asp?url=/libr...lobals_50u1.asp
rob
|
|
|
 |
Rene
|
| Posted: 07/22/2003, 11:35 PM |
|
in CCS2.1,
CCDLookUp("max(Order_number","Orders","1=1",DByourConnectionName)
This will get you the highest number which is the last one
Thanx,
Rene,
|
|
|
 |
Tom
|
| Posted: 07/26/2003, 4:41 PM |
|
See tips http://www.gotocode.com/art.asp?art_id=80&
|
|
|
 |
|