This topic is locked

Auto Fill The Field In The Child Table

7/1/2013 2:55:40 AM
ASPRunnerPro General questions
A
adnankmk author

I have two tables named emp_info and emp_leave with the following details
table 1: Emp_info
emp_id (int)

CNIC (numeric) Primary Key

emp_name (varchar)
table 2: emp_leave

le_id (int)

total_le (int)

availed (int)

CNIC (numeric) Foreign Key
I added a button on the view page of the emp_info table to open the add page of the emp_leave table. I want to set the value of CNIC field of selected employee on the add page filed of emp_leave automatically. How could I do this

G
gdmacdo 7/1/2013

I assume you have joined the tables on the "Table" page of the project and used CNIC as the connector field.The CNIC key should be a field available to select on the emp_leave "Fields" tab of the project. If you only want to display some master/ information on the detail/child, you could create an ASP snippet on the child record:
[font=Calibri]if Session(strTableName & "_masterkey1")<>"" then
[font=Calibri] Session(strTableName & "_masterkey1"),"")
[font=Calibri] Response.Write "CNIC Number: " & rstmp("CNIC") & "
"[size=2] [/size]
[font=Calibri] rstmp.close
[font=Calibri]end if

A
adnankmk author 7/2/2013



I assume you have joined the tables on the "Table" page of the project and used CNIC as the connector field.The CNIC key should be a field available to select on the emp_leave "Fields" tab of the project. If you only want to display some master/ information on the detail/child, you could create an ASP snippet on the child record:
[font=Calibri]if Session(strTableName & "_masterkey1")<>"" then
[font=Calibri] Session(strTableName & "_masterkey1"),"")
[font=Calibri] Response.Write "CNIC Number: " & rstmp("CNIC") & "
"[size=2] [/size]
[font=Calibri] rstmp.close
[font=Calibri]end if


Thanks for replying. I am not understanding where I should write this code. In which event I should use this code.

G
gdmacdo 7/2/2013

You would you use this in an ASP Snippet someplace in your Add/Edit form. In my case, I have a master form where the StudentID is the Primary Key field. I use this code to display the StudentLastName and StudentFirstName on the detail/child form. Since I do not need to store the [size="2"]StudentLastName and StudentFirstName data on the child record, I just want the information displayed so the end user knows the student name they are working with instead of just a number.[/size]
[size="2"]On your Add/Edit page in Visual Editor, you will see an icon in the ribbon (looks like a piece of paper with a pencil) for insert code that has the "Insert ASP Code Snippet" in the dropdown. [/size]



Thanks for replying. I am not understanding where I should write this code. In which event I should use this code.

A
adnankmk author 7/3/2013



You would you use this in an ASP Snippet someplace in your Add/Edit form. In my case, I have a master form where the StudentID is the Primary Key field. I use this code to display the StudentLastName and StudentFirstName on the detail/child form. Since I do not need to store the [size="2"]StudentLastName and StudentFirstName data on the child record, I just want the information displayed so the end user knows the student name they are working with instead of just a number.[/size]
[size="2"]On your Add/Edit page in Visual Editor, you will see an icon in the ribbon (looks like a piece of paper with a pencil) for insert code that has the "Insert ASP Code Snippet" in the dropdown. [/size]


When I run this code it gives VB Script Error Code on this line

set rstmp = dal.Table("EmpInfo").Query("CNIC=" &

G
gdmacdo 7/3/2013

Try the code below without the spaces between lines. Also, are these your exact table names and field names?
if Session(strTableName & "_masterkey1")<>"" then

set rstmp = dal.Table("EmpInfo").Query("CNIC=" &

Session(strTableName & "_masterkey1"),"")

if not rstmp.eof then

Response.Write "CNIC Number: " & rstmp("CNIC") &"
"

end if

rstmp.close

set rstmp=nothing

end if



When I run this code it gives VB Script Error Code on this line

set rstmp = dal.Table("EmpInfo").Query("CNIC=" &