This topic is locked

I want to check a field before I add a new record

3/11/2009 1:44:48 PM
PHPRunner General questions
cyberjas2001 author

I have this 2 tables, Company with the following field Account which is a checkbox, in the other table Container i have this field Payment (which is a dropbox) and Name , and I have the following formula and I want to CHECK this after the User picks a stored Company Name.
[codebox]

if company.account == 1;

{

container.payment == Account; (i want to set this field to ACCOUNT and block it also)

container.amount == 0; (i want to block this field also)

}[/codebox]
And I have the following code, but is not working
[codebox]

global $conn, $strTableName;

$rs = CustomQuery("select Account from company where Account='1' ");

$data = db_fetch_array($rs);

$account = $data["Account"];

if ($values[$Account]==1)

{

$values["Payment"] = 'Account';

$xt->assign("Payment_fieldblock",false);

$xt->assign("Amount_fieldblock",false);

}[/codebox]
I don't know if there's a way to reload the page after I pick the Company Name so it can check the formula posted.

Please I need help, thanks

J
Jane 3/12/2009

Hi,
unfortunately there is no easy way to block field based on the value from another table.
As workaround you can check value in theBefore record addedevent and fill field values in this event:

global $conn, $strTableName;

$rs = CustomQuery("select Account from company where CompanyName='".$values["CompanyName"]."' ");

$data = db_fetch_array($rs);

if ($data["Account"]==1)

{

$values["Payment"] = 'Account';

$values["Amount"] = 0;

}