This topic is locked

AfterAdd() event

3/13/2007 7:06:04 PM
ASPRunnerPro General questions
M
marcove author

Hi, could you help me to have a solution for a question?
Here, it's: How Could I get value of the current RecordID using AfterAdd() event in ASPRunner? Do you have sample code to do it ?

I Wish you could help me

Thank You

marcos

J
Jane 3/14/2007

Marcos,
the event code is dependent on database type (ACCESS or MSSQL SERVER).

Please post your database type and I'll try to help you.

M
marcove author 3/14/2007

Database is MSAccess 2000

Thanks

J
Jane 3/14/2007

Marcos,
here is a sample:

Sub AfterAdd()

str = "select max(RecordID) from " & strTableName

Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open str, dbConnection
'rsTemp(0) - RecordID of added record

Response.Write rsTemp(0)

rsTemp.Close : set rsTemp = Nothing
End Sub

M
marcove author 3/14/2007

Ok thank you. Just a detail:
my table name is : _ProtocolloAmm,

How could change str?Is it correct?
str = "select max(IDPro) from '" & strTableName & "_ProtocolloAmm" & "'"

J
Jane 3/14/2007

Marcos,
strTableName is a global variable with name of current table.

Here is the correct code:

str = "select max(RecordID) from " & strTableName

or

str = "select max(RecordID) from _ProtocolloAmm"