This topic is locked
[SOLVED]

 Autonumber in a field

10/26/2012 3:33:19 PM
ASPRunnerPro General questions
N
Newbe author

Hi, again,
ASP 7.2
I already have an autonumber field in the database named ID.

I also have ProjectID that i would like tobe autopopulated:
I used 2 choices after reading the forum for 3 days. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=20218&image=1&table=forumtopics' class='bbc_emoticon' alt=':)' />
1. added these lines in the before record added

set rstmp = Server.CreateObject("ADODB.Recordset")

rstmp.open "select max(ProjectID)+1 from" & strRegistrations, dbConnection

dict("ProjectID") = rstmp(0).rstmp.close : set rstmp = Nothing


and got this error:

Microsoft Access Database Engine error '80040e14'

Syntax error in FROM clause.
/Registrations_add.asp, line 0


so I guess I got something wrong in syntax: but ASP runer did not find any when checking the code.
choice 2 was to alter query
2. 'ABCD'+String(5-Len(Cstr(ID)),'0')+CStr(ID) as ProjectID,
It was supposed to generate ABCD00001, ABCD00002 etc numbered sequence as soon as the record was going to be inserted.
This does not return anything, and the application is "hanging in the loop"
click registration->add new->enter data-> click save button->just stays in the ADD.asp page - no errors returned

N
Newbe author 10/26/2012

I apologize for this post above, I have solved it.
I have placed the code below in the SQL query.
SELECT

ID,

'ABCD'+String(5-Len(CStr(ID)),'0')+CStr(ID) as ProjectID,
and i had error because I did not erase previous events in the Before Record added.

I actually DELETED all lines, and there was nothing written there.
I had to click on the eraser icon
to have these lines re-appear:



' Place event code here.

' Use "Add Action" button to add code snippets.
BeforeAdd=true


Thank you
I have now ID as autonumber and the ProjectID as autonumber sequenced as needed.
Regards