This topic is locked

Help with Record Add page

12/17/2008 4:20:48 PM
PHPRunner General questions
vin7102 author

Hello,
I have an Add New Record page for "Payroll_Main" which among others, has a field called "Employee_ID" and also "Employee_Name".

"Employee_Name" is a look up field from a table called "payroll_employee_list"
The "payroll_employee_list" table has an "Employee_Name" field and an "Employee_ID" field with the "Employee_ID" being the key field.
Is it possible to have the "Employee_ID" field in the Add New Record page automatically fill the corresponding "Employee ID" read only field whenever

the Employee name is selected from the look up field so that when the record is updated they are both entered into the list page?
Any Ideas would be greatly appreciated.
Thanks in advance

Vince

J
Jane 12/18/2008

Vince,
I recommend you to remove Employee_ID from the add page and fill it manually in the Before record added event on the Events tab.

Here is a sample:

global $dal;

$rs = $dal->payroll_employee_list->Query("Employee_Name='".$values["Employee_Name"]."'","");

$data = db_fetch_array($rs);
$values["Employee_ID"] = $data["Employee_ID"];

vin7102 author 12/18/2008

Hi Jane,
I did as you suggested and removed the Employee_ID from the add page and the Code works Perfectly.. Thank You.

I'm also trying to use this code for another field in my project but can't seem to get it to work.

Would the code change if the "Employee_ID" field was not the key field in the table? Its the only thing different besides the field values.
along with the previous event you gave me I am trying to do the same with this set:
I have an Add New Record page for "Payroll_Main" which among others, has a field called "Job_Description" and also "Job_Name".

"Job_Name" is a look up field from a table called "payroll_Job_list"
The "payroll_Job_list" table has a "Pay_Jobs" field and a "Pay_Job_Desc" field with "ID" being the key field.
Like the last code, Im trying to get the "Job_Description" field autofilled with its corresponding "Pay_Job_Desc" value when the Job_Name is selected from the look up list.
Thanks again

Vince

vin7102 author 12/18/2008

Sorry Jane,

I figured my own problem out.. I was missing an Underscore on a field name..
Thanks Anyways

Vince