This topic is locked

Default Value From Another table

10/13/2005 3:39:35 PM
ASPRunnerPro General questions
W
WeB author

I have two tables
TABLE1

record_id

username

date

desired_date

email
TABLE2

username

password

email
Table2 just holds the users for logins. I have Table1.username defaulted to Session("UserID") which works great. I want to default Table1.email to table2.email for the corresponding user. What is the best way?

Sergey Kornilov admin 10/14/2005

Hi,
set default value for email field in Table1 as Session("Email").

Generate ASP pages.

Open login.asp file, find these lines:

if request("username")=CStr(rs(cUserNameField)) and request("password")=CStr(rs(cPasswordField)) then

      Session("UserID") = Request("username")


and insert this one right after them

Session("Email") = rs("email")

W
WeB author 10/14/2005

Thanks a bunch Sergey im sure that will work when I set it up tonight. A question I had though is if another user signs in and edits a record will the email address change? If so is there a way so it stays to the original email address?

W
WeB author 10/14/2005

It appears as though if I have the field on the edit page the creater of the recored will stay put, but if I choose to not show the field on the edit page then it will change to whoever is editing the record. I dont want to show the field on the edit page but I do want the data in the email field to stay at the record creaters info.
what are your thoughts?

Sergey Kornilov admin 10/17/2005

If you simply remove this field from the EDIT page it won't be updated when record is edited. Just uncheck Edit page check box against this field on the Formatting tab in ASPRunnerPro.