This topic is locked

Default Field Value

7/28/2008 4:58:01 PM
ASPRunnerPro General questions
T
tgunther author

Is there a way to have an SQL query be the default value of a read only field on the add page? For instance could you put a query of say:

SELECT MAX(ID) FROM dbo.detail

.

Thanks in advance!

J
Jane 7/29/2008

Hi,
to select max value from table use Add page: Before process event on the Events tab.

Here is a sample:

str = "SELECT MAX(ID) as MAXID FROM dbo.detail"

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

rstmp.open str,dbConnection
Session("MAXID") = rstmp("MAXID")
rstmp.close

set rstmp=nothing



Then use Session("MAXID") as default value for your readonly field on the "Edit as" settings dialog on the Visual Editor tab.

M
mengo 2/8/2009

Hi,

to select max value from table use Add page: Before process event on the Events tab.

Here is a sample:
Then use Session("MAXID") as default value for your readonly field on the "Edit as" settings dialog on the Visual Editor tab.


Hi,

I have two dependent dropdowns on add page. I want to assign default value to first dropdown and did it by Lookup wizard's(asprunner) default value window. But it seems there is a problem. Default value appears in first dropdown but second one is not functional. To enable 2nd dropdown I have to select any other value in 1st dropdown then It becomes functional. Can I do it through events by the similar code above? Could you advise what the problem is or code I have to add to events?
Thanks

J
Jane 2/9/2009

Hi,
please make sure you use latest ASPRunnerpro build 766.
If it doesn't help publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.