This topic is locked

Default Values

11/6/2006 11:30:26 AM
ASPRunnerPro General questions
B
bleckron author

When on the master detail page, If I Click Add New the form is blank. I would like some of the values on the master Detail page to automatically populate into the Add New page. I assume this is done thourgh the default values but not sure how to go about it. Thanks for your help.
Brad

Sergey Kornilov admin 11/7/2006

Brad,
here is how you can do this.

  1. Use OnLoad event of detail table to populate session variables with values from master table.
    Sub ListOnLoad()

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

    rstmp.open "select * from MasterTable where MasterTablePrimaryKey = " & SESSION(strTableName & "_masterkey1"), dbConnection
    Session("MasterField1") = rstmp("MasterField1")

    Session("MasterField2") = rstmp("MasterField2")
    rstmp.close : set rstmp = nothing
    End Sub


2. Now you can use Session("MasterField1") and Session("MasterField2") as default values.
Make sure you replace names in bold with real table and field names.