This topic is locked

Dropdown List - Add on the fly

5/28/2007 5:44:36 AM
ASPRunnerPro General questions
R
ryn004 author

If I'm editing a table with information on a item and I have a dropdown menu to select the seller, if the seller is not in the list I click on "add new". However is it possible to enter al lthe details of the seller (name, telephone, email...etc) and not just the related field?

J
Jane 5/28/2007

Hi,
unfortunately its' impossible to add info to another table on the fly.
Here is a workariund.

  1. save value of seller field in the Session variable in the Before record updated event on the Events tab:
    Function BeforeEdit(dict, where)

    Session("seller") = dict("seller")

    BeforeEdit = True

    End Function

where seller is your actual field name.
2. redirect to the edit page of this seller in the After record updaded event:

Sub AfterEdit()

str = "select * from SellerTable where seller='" & Session("seller")& "'"
Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open str, dbConnection
Response.Redirect "SellerTable_edit.asp?editid1=" & rsTemp("PrimaryKey")

rsTemp.Close : set rsTemp = Nothing
End Sub



where SellerTable is your actual table name, PrimaryKey is yout actual field name where primary key is stored.

R
ryn004 author 5/28/2007

Thanks but I didn't want to go about it that way. What if I leave the "add new" link by choosing "Allow to add new values on the fly" and that will create a new id and name in the seller table.

I would then customize a link "edit" near the "add new" link which will open a popup window (e.g. /tblSeller_edit.asp?editid1=12). My problem is how to retrieve what seller is currently selected in the dropdown box so i can redirect the user to the correct edit page.