Re: Best Place to put CDNewID() if not put in the table or v

Author: Bhavbhuti Nathwani

Posted: 2004-01-08 at 08:18:19

Quote: >>This is already done for you in the OnNew() method, if you

have that set as the default value for the iID field. BeforeNew()

wouldn't work, since the new record isn't created yet - you would be

changing the ID of the current record there. AfterNew() could also

work, but that is fired after SetMemento(), so that changing the ID

there would mark the record as modified, requiring the "Do you want to

save your changes?" message box if the user immediately cancels the

Add.

Actually this is the code I have still under construction:

<code>

LOCAL llRetVal, loLastRecord, lnConHnd, liID, lnNextId

llRetVal = DODEFAULT()

lnConnHnd =

SQLSTRINGCONNECT("DSN=C99_VSO3Data_FireBird;DRIVER=OdbcJdbc;DBNAME=D:\Shared\C99\Data\VSO3.FDB;UID=SYSDBA;PWD=masterkey")

= SQLEXEC(lnConnHnd , [SELECT

gen_id(GEN_MSALESREPS_ID,1) AS lnNextId from

rdb$VSO3])

liID = lnNextId

wait window str(liID) + str(lnNextId)

RETURN llRetVal

</code>

So in essence I am replacing the default for the view, is end of

beforenew() good enough. I have called the dodefault() and studying

the inherited code I assumed that the record is append blank somewhere

down the line, thus my decision.

Please advise. I want the functionality of default CBNewID() but

programatically.

Thanks.

©2004 Bhavbhuti Nathwani