styrochem
Posts: 7
|
Posted: 03/16/2005, 6:42 AM |
|
I am a newbie to CodeCharge and need some assistance with this issue. We have a registration system that retrieves the last recorde entered autonumber from an Access database. Basically, you enter the information on page 1 and then it returns with the autonumber that was assigned to that record. Does anyone know of some steps I can utilize when attempting to program this task into CodeCharge? I have attempted many different options with no results.
|
|
|
peterr
Posts: 5971
|
Posted: 03/17/2005, 2:03 AM |
|
Yes, the "Multi-Step User Registration" example at http://examples.codecharge.com/ExamplePack/MultiStepReg...trationGrid.php does the same thing.
It is a part of CCS Example Pack included in CCS.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
styrochem
Posts: 7
|
Posted: 03/18/2005, 6:13 AM |
|
Maybe I am missing something as I have been working on this project alot lately. The example says in Page2 MultiStepRegistration1 to add appropriate code in the Record form's After Insert Event which I assume is where I enter the code to retrieve the last record entered ID from the database. What is the example code I am supposed to use that impliments this command? The directions say as shown in the example but I don't see a code example.
|
|
|
Oper
Posts: 1195
|
Posted: 03/18/2005, 8:51 AM |
|
To Get last record Inserted by 1 user.
we always have 1 field on that table named UNIQUECODE
so we alwasy record the UNIQUECODE using any string generated by us like:
before show event.
FormName.UNIQUECODE.value=ccgetuserid() & "-" & hex(datediff("s","1/1/2003",now()))
and to get last id use after insert event
lastid=ccdlookup("id","tabel","UNIQUECODE=" & FormName.UNIQUECODE.value,"DBConenction1")
Quick withotu event testting so check parentesys and apostrophes
Note: you Coudl add rnd() if same user logged at same time different computer.
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)
http://www.PremiumWebTemplate.com
Affiliation Web Site Templates
Please do backup first |
|
|
peterr
Posts: 5971
|
Posted: 03/20/2005, 10:02 AM |
|
styrochem,
If you don't see the example code then possibly you haven't created your example project yet. There are instructions available at http://docs.codecharge.com/studio/html/ProgrammingTechn...xamplePack.html
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
GeorgeS
Posts: 206
|
Posted: 03/20/2005, 4:26 PM |
|
Here is what I'm using for getting autonum Access ID:
-------------------------------------------------------------------------------------------------
Function tblClients_DataSource_AfterExecuteInsert()
' -------------------------
Dim NewID, varID
Set NewID = DBconnection.Execute("SELECT @@IDENTITY")
varID = NewID(0) ' Store the value of the new identity in a variable
_________________
GeorgeS |
|
|
styrochem
Posts: 7
|
Posted: 03/21/2005, 4:34 AM |
|
Quote GeorgeS:
Here is what I'm using for getting autonum Access ID:
-------------------------------------------------------------------------------------------------
Function tblClients_DataSource_AfterExecuteInsert()
' -------------------------
Dim NewID, varID
Set NewID = DBconnection.Execute("SELECT @@IDENTITY")
varID = NewID(0) ' Store the value of the new identity in a variable
GeorgeS:
Do I insert this into the code after update on the confirmation page?
|
|
|
GeorgeS
Posts: 206
|
Posted: 03/21/2005, 11:20 AM |
|
this is the code for your first page for AfterExecuteInsert ivent.
you may pass the value of the new ID to your next page via Session or query string
_________________
GeorgeS |
|
|
styrochem
Posts: 7
|
Posted: 04/04/2005, 5:20 AM |
|
How do I query this value on the next page? Also, if using the SQL statement of SELECT @@IDENTITY , couldn't I possibly receive the last inserted record value from any of the tables in the database? My table for this task is called tblDoc.
Forgive my lack of knowledge here but this is new to me...
|
|
|
Nicole
Posts: 586
|
Posted: 04/05/2005, 1:50 AM |
|
To retrieve a new primary key value from the certain table (not any other) you can use query like
select @@identity as lastpk from table_name where table_name. primary_key_field_name =@@identity
and put execute query code in After Execute Insert event.
_________________
Regards,
Nicole |
|
|