This topic is locked

Default Value

12/13/2007 8:18:50 PM
ASPRunnerPro General questions
author

I know this has to be simple, but I cannot figure it out. I want to set a field value based on the query of an external table.
strORGKEY = "SELECT TOP 1 ORGKEY_ID FROM tblORGKEY"
ORGKEY = strORGKEY
Can I do this somehow on the Visual Editor for the field or do I do it as an Event?
Thanks for any ideas!

M
Michael7 12/13/2007

this should work
USE the addonload event
'** Get Orgkey ****

strSQLorgkey = "SELECT TOP 1 ORGKEY_ID FROM tblORGKEY ORDER BY ORGKEY_ID DESC"

set rsorgkey = CreateObject("ADODB.Recordset")

rsorgkey.Open strSQLorgkey, dbConnection
rsorgkey.movefirst

DIM ORGKEY

ORGKEY = rsorgkey("ORGKEY_ID")

' Response.Write ORGKEY
rsorgkey.Close : set rsorgkey = Nothing
'** End of Code *****
then just set the default value to the ORGKEY variable "& ORGKEY &"
Michael

M
MarkH 12/28/2007

this should work

USE the addonload event
'** Get Orgkey ****

strSQLorgkey = "SELECT TOP 1 ORGKEY_ID FROM tblORGKEY ORDER BY ORGKEY_ID DESC"

set rsorgkey = CreateObject("ADODB.Recordset")

rsorgkey.Open strSQLorgkey, dbConnection
rsorgkey.movefirst

DIM ORGKEY

ORGKEY = rsorgkey("ORGKEY_ID")

' Response.Write ORGKEY
rsorgkey.Close : set rsorgkey = Nothing
'** End of Code *****
then just set the default value to the ORGKEY variable "& ORGKEY &"
Michael


I used this code which worked fine up to the point it actually writes ORGKEY on the add page. But I had no success making it appear as the default (the last instruction). Exactly what should be placed as the default setting? I tried both ORGKEY and "& ORGKEY &".

Sorry, I´m a newbie...

Thanks a lot in advance,

Mark

Sergey Kornilov admin 12/29/2007

Save recordset value to session variable:
Session("ORGKEY") = rsorgkey("ORGKEY_ID")
and use Session("ORGKEY") as a default value.
One more thing - I recommend to use BeforeProcess event for this purpose.